Obj-C:与@“string”

我见过有人做类似[NSString stringWithString:@"some string"] 。 为什么不只是做@"some string" ? 举个例子,看看facebook-ios-sdk 。 + [NSString stringWithString:] – 有什么意义? 是一个类似的问题,但没有答案地址[NSString stringWithString:@"some string"]与@"some string" 。

每当我的应用程序启动时,为什么我会在执行“-layoutSubviews”后仍然需要“自动布局”?

由于我添加了下面的代码,每当我的应用程序打开这个UITableViewController它崩溃: self.noArticlesView = [[UIView alloc] init]; self.noArticlesView.translatesAutoresizingMaskIntoConstraints = NO; self.noArticlesView.backgroundColor = [UIColor colorWithRed:0.961 green:0.961 blue:0.961 alpha:1]; [self.view addSubview:self.noArticlesView]; [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.noArticlesView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0]]; [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.noArticlesView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0]]; [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.noArticlesView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0]]; [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.noArticlesView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0]]; 它给了我这个错误: […]

防止UIAlertControllerclosures

我想阻止UIAlertController被解雇。 我有一个UIAlertAction ,只是将一个string追加到UIAlertTextField中,但是,一旦点击它,视图控制器[不希望的]。 我试着添加一个NSNotification与不希望的结果。 UIAlertAction *pasteMessage = [UIAlertAction actionWithTitle:@"Paste Message" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { UITextField *textField = alertC.textFields.firstObject; textField.text = [textField.text stringByAppendingString:[NSString stringWithFormat:@"%@", copiedString]]; }]; 我也试过设置no来通过pasteMessage: [alertC canPerformAction:@selector(dismissViewControllerAnimated:completion:) withSender:pasteMessage]; -(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion { UIAlertController *alertController = (UIAlertController *)self.presentedViewController; UIAlertAction *paste = alertController.actions.firstObject; if (paste) { flag = NO; } else { flag = YES; } […]

删除checkbox的“已选中”属性

发生错误时,我需要删除一个checkbox的“checked”属性。 .removeAttr函数不起作用。 任何想法? :/ HTML <div data-role="controlgroup" data-type="horizontal" data-mini="true" style="margin-left: auto; margin-right: auto; width: 100%; text-align: center;"> <input type="checkbox" id="captureImage" name="add_image" class="custom" /> <label for="captureImage" data-icon="checkbox">Image</label> <input type="checkbox" id="captureAudio" name="add_audio" class="custom" /> <label for="captureAudio" data-icon="checkbox">Audio</label> <input type="checkbox" id="captureVideo" name="add_video" class="custom" /> <label for="captureVideo" data-icon="checkbox">Video</label> </div> 使用Javascript $("#captureImage").live("change", function() { // $("#captureImage").prop('checked', false); // Here Work […]

在iOS10中replaceARKit

如果iOS版本<11,我想将ARKit包含在为iOS10 +devise的应用程序中,在那里我用SceneKitreplaceARKit。 不幸的是,似乎目前没有办法做到这一点?

iOS:作为后台任务运行时可以截屏吗?

我想截取任何正在运行的应用程序,而我的应用程序在后台。 我知道我可以在iOS中使用截图: UIGraphicsBeginImageContext(webview.frame.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil); 但是这在后台任务中是不可能的,因为UIGraphicsGetCurrentContext返回NULL,我想要一个正在运行的应用程序的屏幕截图,而不是我的视图。 有没有其他的方法?

将parameter passing给@selector方法

我在表格视图中添加了一个UIButton 。 现在,当我点击一个特定的button,我需要获取该行对应的对象的细节。 [button addTarget:self action:@selector(invite:contactmail:) forControlEvents:UIControlEventTouchUpInside]; 我已经使用这个button的方法; 我怎么能传递参数给这个select器方法? 还是有任何其他的方式来传递参数,当这个button被点击这个方法?

如何在音乐播放器中制作倒数计时器?

我有一个标签,它的值是“03:48”。 我想像一个音乐播放器倒计时。 我怎样才能做到这一点? 03:48 03:47 03:46 03:45 … 00:00 var musictime =3:48 func stringFromTimeInterval(interval: NSTimeInterval) -> String { let interval = Int(interval) let seconds = interval % 60 let minutes = (interval / 60) return String(format: "%02d:%02d", minutes, seconds) } func startTimer() { var duration=musictime.componentsSeparatedByString(":") //split 3 and 48 var count = duration[0].toInt()! * 60 […]

在视图控制器之间传递数据:从uitableview到详细信息视图控制器

我正在使用IOS 5和故事板编码。 我已经build立了一个应用程序,我有一个tableView连接到一个search栏的SQLite数据库。 当我们触摸一行时,它会自动将我们带到另一个名为“Details”的视图控制器。 我需要将数据从我的表视图传递给详细信息视图控制器,例如将author.title传递给labelText.text字段。 有任何想法吗? 编辑的问题: – (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ // NSString *Title; Details *dv = (Details*)segue.destinationViewController; author.title = dv.labelText.text; } 部分代码: // // Details.m // AuthorsApp // // Created by georges ouyoun on 7/17/12. // Copyright (c) 2012 __MyCompanyName__. All rights reserved. // #import "Details.h" #import "Author.h" @interface Details () @end @implementation Details […]

使计时器在后台iOS上运行超过3分钟

所以我需要这个应用程序运行超过3分钟的计时器,并播放声音非常45秒,这里的大多数解决scheme只是不到3分钟在iOS上。 除非应用程序停止,否则有办法让它始终运行吗? 经过研究,我猜解决scheme是实现beginBackgroundTaskWithExpirationHandler 并通过在plist上给予一个handler并设置位置更新来停止它? 至于audio,除了放置plist,还有其他什么需要做audio播放? Swift如何使用NSTimer背景? iphone – NSTimers在后台在后台 运行应用程序超过10分钟