我增加了UITextField一个UIAlertController,这似乎为AlertView.在解雇之前UIAlertController,我想验证输入UITextField.基于验证,我想解雇UIAlertController或不解雇.但我不知道如何防止UIAlertController按下按钮时的解除动作.有没有人解决这个问题或任何想法从哪里开始?我去谷歌但没有运气:/谢谢!
我将用户从我的应用程序发送到浏览器,然后通过我的自定义URL将其返回到应用程序.问题是:一旦我返回,我的所有实例变量都是空的!接口被保留(正如我使用Storyboard时预期的那样),但是(文本字段,实例变量等)的值是不可访问的...它们返回null.
这是怎么回事??
当应用程序收到推送通知时,我试图在didReceiveRemoteNotification中显示来自appDelegate的UIAlertView.
我有这个错误:
Warning: Attempt to present <UIAlertController: 0x14c5494c0> on <UINavigationController:
0x14c60ce00> whose view is not in the window hierarchy!
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: NSDictionary) {
var contentPush: NSDictionary = userInfo.objectForKey("aps") as NSDictionary
var message = contentPush.objectForKey("alert") as String
let alertController = UIAlertController(title: "Default Style", message: message, preferredStyle: .Alert)
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) in
// ...
}
alertController.addAction(cancelAction)
let OKAction = UIAlertAction(title: "OK", style: .Default) { (action) in
let photoPushedVc = self.storyboard.instantiateViewControllerWithIdentifier("CommentTableViewController") as CommentTableViewController …Run Code Online (Sandbox Code Playgroud) 我希望UITextField在用户输入时动态地将逗号添加到我的数字条目中.
例如:123,456和12,345,678,但不是这样123,45或123,4567.
当用户在Objective-C中键入数字时,如何自动附加逗号?
编辑:我也希望能够允许用户输入小数.
我有一个带有一些选项的按钮.
- (IBAction)monstrarActionSheet:(id)sender {
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@"Titulo"
delegate:self
cancelButtonTitle:@"Mejor no" destructiveButtonTitle:@"Que miedo" otherButtonTitles:@"Otro boton 1", @"Otro boton 2", nil];
[action showInView: self.view];
Run Code Online (Sandbox Code Playgroud)
选择某个选项后,我会在日志中显示一条消息,以显示选择了哪个按钮.
-(void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
/*if(actionSheet.tag == 1){
}*/
NSLog(@"El usuario seleciono el boton %ld", (long)buttonIndex);
}
Run Code Online (Sandbox Code Playgroud)
在我的ViewController.h我的按钮和标签是这样定义的
@interface ViewController : UIViewController <UIActionSheetDelegate>
@property (weak, nonatomic) IBOutlet UILabel *lbViewController1;
Run Code Online (Sandbox Code Playgroud)
如何将所选UIActionSheet按钮的标题放入我的lbViewController1标签中?
我遇到的问题似乎不应该是真正的问题。我正在尝试为我的应用创建评论(“聊天”)视图,但是我使用的是估计的行高,因此找不到一种从底部开始进行评论的好方法,例如,在加载视图时,最新评论位于屏幕底部,也位于屏幕底部输入区域的上方。
我已经寻找了很多年了,并找到了以下解决方案:
[self.tblComments scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
Run Code Online (Sandbox Code Playgroud)
效果不佳,因为它使用了估计的行高,但并不总是正确的(某些注释会更长)。
[self.tblComments setContentInset:UIEdgeInsetsMake(self.tblComments.bounds.size.height - self.tblComments.contentSize.height, 0, 0, 0)];
Run Code Online (Sandbox Code Playgroud)
与上述相同的问题(contentSize由estimateRowHeight确定)。
我敢肯定某个地方有一个完美的解决方案,因为这么多应用程序都具有这样的视图,但我找不到它。我希望对我可能在这里缺少的东西有任何见解...
刚刚更新到swift 2.0,我遇到了错误.
我得到的错误是:'array'不可用:请从你的懒惰序列构造一个数组:Array(...)
我的代码是:
if let credentialStorage = session.configuration.URLCredentialStorage {
let protectionSpace = NSURLProtectionSpace(
host: URL!.host!,
port: URL!.port?.integerValue ?? 0,
`protocol`: URL!.scheme,
realm: URL!.host!,
authenticationMethod: NSURLAuthenticationMethodHTTPBasic
)
// ERROR------------------------------------------------?
if let credentials = credentialStorage.credentialsForProtectionSpace(protectionSpace)?.values.array {
// ERROR------------------------------------------------?
for credential: NSURLCredential in (credentials) {
components.append("-u \(credential.user!):\(credential.password!)")
}
} else {
if let credential = delegate.credential {
components.append("-u \(credential.user!):\(credential.password!)")
}
}
}
Run Code Online (Sandbox Code Playgroud)
有谁知道如何转换这行代码来更新Swift 2.0?
if let credentials = credentialStorage.credentialsForProtectionSpace(protectionSpace)?.values.array
下面显示的代码就是我已经尝试过的.我希望实现的是从设备中获取所有照片.目前只有少数被提取.如何修改代码以便从设备加载所有图像?
let fetchOptions = PHFetchOptions()
let collection:PHFetchResult = PHAssetCollection.fetchAssetCollectionsWithType(.Moment, subtype: .Any, options: fetchOptions)
if let first_Obj:AnyObject = collection.firstObject
{
self.assetCollection = first_Obj as! PHAssetCollection
}
Run Code Online (Sandbox Code Playgroud) 我在Xcode 6中有一个主视图控制器(程序是快速的),我有几个按钮,通向某些导航控制器.当我测试应用程序时,我第一次看到它看起来很好(顶部没有导航栏).当我单击主视图控制器上的按钮时,它会显示我选择的导航控制器,一切都会再次完美.当我点击该导航控制器上的"后退"栏按钮以便它再次向我显示我的主视图控制器时,会出现问题.当我回到主视图控制器时,顶部有一个导航栏,不应该在那里.我希望我的主视图控制器顶部没有导航栏.我尝试使用push,modal和show segues来查看它是否可能是问题,但我仍然无法弄明白.对可能发生的事情的任何想法?
ios ×8
swift ×6
objective-c ×3
alamofire ×1
arrays ×1
photos ×1
swifty-json ×1
uitableview ×1
uitextfield ×1
view ×1