小编tha*_*oru的帖子

UIView内部的UIButton在UIView动画后无法正常工作

我在这个论坛上看到很多问题给出了这个主题的答案"当UIView内部的UIButton,当动画不起作用时",但是在尝试了像这样的答案之后

a) UIViewAnimationOptionAllowUserInteraction to the options
b) subView.setUserInteractionEnabled = YES
c) [button addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
Run Code Online (Sandbox Code Playgroud)

他们都没有为我工作:-(

这是场景.App处于横向模式,名为menuView的UIView位于x = 480,y = 0.它的高度= 200,宽度= 150.因此,当我点击右上角的按钮时,将执行以下代码

- (IBAction)showMenu {
    [menuView setUserInteractionEnabled:YES];
    [optionsButton setUserInteractionEnabled:YES];
    [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationCurveEaseOut |  UIViewAnimationOptionAllowUserInteraction
                     animations:^{
                         self.view.frame = CGRectOffset(self.view.frame, 0, 200);
                     }
                     completion:NULL];
}
Run Code Online (Sandbox Code Playgroud)

输出?:视图正在显示,但menuView中的optionsButton无法点击.我联系了一个事件,做了一个NSLog(@"选项按钮点击"),但没有任何反应:-(

请告诉我我做错了什么?

更新:当我在self.view中放置"menuView"子视图时,然后在运行并单击optionsButton时,我得到NSLog消息.只有当我将menuView的origin.x指定为480及以上时,它才会起作用.

objective-c uibutton uiviewanimation

11
推荐指数
2
解决办法
2万
查看次数

iOS中的拨号号码真的需要确认吗?

我使用以下代码拨打号码并使用我的设备进行测试.似乎不需要确认,对吗?

NSURL *url = [NSURL URLWithString:@"tel://12345678"];
[[UIApplication sharedApplication] openURL:url];
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c ios4 ios

5
推荐指数
2
解决办法
5211
查看次数

拳击NSString stringWithFormat像NSNumber

我们可以像这样创建一个NSNumber

NSNumber *number = [NSNumber numberWithFloat:4.5];
//or
NSNumber *number = @(4.5);
//or
NSNumber *number = @4.5;
Run Code Online (Sandbox Code Playgroud)

我知道我们可以使用以下语句转换为NSString

NSString *string = @("stuff"); //equivalent of [NSString stringWithUTF8String]
Run Code Online (Sandbox Code Playgroud)

但是,我们可以像这样创建一个NSString吗?

NSString *string = @(@"Name is:%@",name); //equivalent of [NSString stringWithFormat]
Run Code Online (Sandbox Code Playgroud)

objective-c nsstring ios

4
推荐指数
1
解决办法
839
查看次数

在iPhone模拟器上显示谷歌地图 - Phonegap

我正在运行Mac OSX Lion和Xcode 4.1.1.我创建了一个新的Phonegap项目,在index.html中,我添加了以下代码.

<!DOCTYPE html>
<html>
    <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />

    <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js">
    </script>

    <!-- Tried setting sensor=true, didn't work too -->
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
    </script>

    <script type="text/javascript" charset="utf-8" >

    function display(position){
        var initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
        var myOptions = {
                zoom: 12,
                center: initialLocation,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
        }

        function error()
        {
            alert('Not working');
        }

        function init()
        {
            navigator.geolocation.getCurrentPosition(display,error);
        }
        </script>
    </head>
    <body …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps-api-3 ios4 xcode4 cordova

3
推荐指数
1
解决办法
4507
查看次数

使用动态ID滚动到UL列表中的特定元素

我读了一个问题Scroll到一个特定元素w/jQuery,在问题中,原始的HTML代码已经有段落元素的id.但是,就我而言,我动态生成元素(列表元素)并在运行时创建ID.如何使用或不使用jQuery滚动到该特定元素?

要提供有关我的问题的更多细节:

我正在创建一个phonegap项目来获取iPhone中的联系人列表,并在div中显示滚动列表(我使用iscroll插件).我将名字AE,FJ,KO,PT,UZ分类并将它们分组.如果用户触摸侧面的FJ(正如您在iPhone联系人应用程序中找到的那样),则div应滚动到属于FJ组的第一个联系人.

<div id ="tablediv">
    <div id="scroller"></div>
</div>

<div id="sorter">
    <span id="gr1">A-E</span>
    <span id="gr2">F-J</span>
</div>
Run Code Online (Sandbox Code Playgroud)

使用Javascript:

var g1 = ['a','b','c','d','e'];  //contact's first name starting with these chars
var g2 = ['f','g','h','i','j'];  //contact's first name starting with these chars
var idg1=null, idg2=null; // first id of the contact which was in g1, g2

//Array is an array of objects
//example: array = [ {'fname':'x','lname':'y','number':'123'},{..},{..}];

function generateTable(array) {
    gpDiv = document.getElementById("scroller");
    pDiv = document.createElement("ul");
    pDiv.id = "thelist";
    for(var i=0;i<array.length;i++) …
Run Code Online (Sandbox Code Playgroud)

javascript jquery scroll cordova

3
推荐指数
1
解决办法
5454
查看次数

使用Jquery和jgestures在Cordova中滑动

在使用jQuery/jQuery mobile进行滑动时,Stackoverflow中有很多主题.但是,它们似乎都没有按照我想要的方式工作.以下是我的phonegap应用程序的索引页面的结构.正如主题推荐的那样,我尝试了jgestures插件.

<html>
<head>
<title>App</title>
<script type="text/javascript" src="lib/cordova-2.2.0.js"></script>
<script type="text/javascript" src="lib/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="lib/jgestures.js"></script>
</head>
<body>
<div id="home">
    <div id="headersec">
        <!-- some elements like images here-->
    </div>
    <div id="screen1">
        <!-- three 80x80 images go here -->
    </div>
    <div id="screen2">
        <!-- three other 80x80 images go here-->
    </div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我想在我的deviceready事件中做的就是这个

document.addEventListener("deviceready",onDeviceReady,false);

function onDeviceReady() {
    $('#screen1').bind('swipeleft',showNext); //show next hides screen1, shows screen2 
    $('#screen2').bind('swiperight',showPrev);//show prev hides screen2, shows screen1
}
Run Code Online (Sandbox Code Playgroud)

但这不适用于我尝试的任何示例代码.任何人都可以告诉我做错了什么?

jquery swipe-gesture

3
推荐指数
1
解决办法
1万
查看次数

通过应用程序的plist文件阻止iPhone自动锁定

有没有办法阻止iPhone通过应用程序的plist自动锁定.更具体地说,一个PhoneGap应用程序?

我编写了一个使用Phonegap框架的应用程序.在其中,我有很少的自定义插件,其中包含了代码

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
Run Code Online (Sandbox Code Playgroud)

禁用自动锁定.但是如果存在plist选项以便我可以通过plist而不是通过代码来配置应用程序,那将会非常棒.

干杯!

iphone ios cordova

2
推荐指数
1
解决办法
1528
查看次数