我已经阅读了苹果文档,这对于Objective-C像我这样的初学者来说是不可理解的.我正在尝试UITableView按照这个 链接示例实现多列,它只是不起作用所以我需要理解如何cellForRowAtIndexPath工作,因为我个人这个方法似乎相当复杂.
1)它返回什么?UITableViewCell?但为什么它看起来如此奇怪?
-(UITableViewCell *)tableView:(UITableView *)tableView
Run Code Online (Sandbox Code Playgroud)
2)如何调用它,更重要的是如何将它连接到某个UITableView??? 如果我有两个UITableView名字firstTableView并且secondTableView我希望它们不同(表现cellForRowAtIndexPath不同)怎么办?我UITableViews该如何将自己与此联系起来
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
方法接受NSIndexPath,而不是UITableView.我该怎么办?
我正在使用3.2 sdk开发iPad应用程序.我正在处理获取键盘大小以防止我的文本字段隐藏在它后面.
我在Xcode中收到警告 - > UIKeyboardBoundsUserInfoKey已弃用,我应该使用什么而不是获取此警告?
我有一个带有GIF横幅的字符串,我需要将其放入应用程序.
我的代码:
func showAdd(){
Request.get("http://www.kyst.no/api/?apiMode=advertisement&lang=no", { (error: NSError?, data: NSData, text: NSString?) -> () in
let jsonResult: Dictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil) as Dictionary<String, AnyObject>
var banner : NSString = jsonResult["advertisement"]!["banner"] as NSString
self.addViewImage.image = UIImage.animatedImageNamed(banner, duration: 1)
})
}
Run Code Online (Sandbox Code Playgroud)
但没有任何反应.请帮忙.
该image.size属性UIImageView给出了原来的大小UIImage.我想知道放入的自动缩放图像的大小UIImageView(通常小于原始图像).
例如,我将图像设置为Aspect Fit.现在我想知道它在屏幕上的新高度和宽度,以便我可以准确地在新的缩放图像上绘制.
有没有办法做到这一点,而不是根据UIImageView大小和UIImage原始大小自己搞清楚(基本上是逆向工程缩放)?
我知道打开闪光灯并在iPhone 4上保持打开的唯一方法是打开摄像机.我不太确定代码.这是我正在尝试的:
-(IBAction)turnTorchOn {
AVCaptureSession *captureSession = [[AVCaptureSession alloc] init];
AVCaptureDevice *videoCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoCaptureDevice error:&error];
if (videoInput) {
[captureSession addInput:videoInput];
AVCaptureVideoDataOutput* videoOutput = [[AVCaptureVideoDataOutput alloc] init];
[videoOutput setSampleBufferDelegate:self queue:dispatch_get_current_queue()];
[captureSession addOutput:videoOutput];
[captureSession startRunning];
videoCaptureDevice.torchMode = AVCaptureTorchModeOn;
}
}
Run Code Online (Sandbox Code Playgroud)
有人知道这是否有效还是我错过了什么?(我还没有iPhone 4进行测试 - 只是尝试了一些新的API).
谢谢
我试图在iOS 8中检测应用程序的本地通知设置
对UIUserNotificationSettings,它返回我7我已经把所有的徽章,声音和提醒.
在设置中,我关闭"允许通知",应用程序仍然返回我的UIUserNotificationSettings(徽章,声音和警报).有没有办法检测"允许Notification"开/关?
- (void)application:(UIApplication *)application
didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{
NSLog(@"---notificationSettings.types %d" , notificationSettings.types );
if(notificationSettings.types!=7){
UIAlertView * alert =[[UIAlertView alloc ] initWithTitle:@"Please turn on Notification"
message:@"Go to Settings > Notifications > App.\n Switch on Sound, Badge & Alert"
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[alert show];
}
}
Run Code Online (Sandbox Code Playgroud) 在管理键盘文档中:
UIKeyboardFrameBeginUserInfoKey包含CGRect的NSValue对象的键,用于标识 屏幕坐标中键盘的起始帧.这些坐标不考虑由于界面方向改变而应用于窗口内容的任何旋转因子.因此,您可能需要在使用之前将矩形转换为窗口坐标(使用convertRect:fromWindow:方法)或查看坐标(使用convertRect:fromView:方法).
UIKeyboardFrameEndUserInfoKey包含CGRect的NSValue对象的键,用于标识 屏幕坐标中键盘的结束帧.这些坐标不考虑由于界面方向改变而应用于窗口内容的任何旋转因子.因此,您可能需要在使用之前将矩形转换为窗口坐标(使用convertRect:fromWindow:方法)或查看坐标(使用convertRect:fromView:方法).
是什么意思start frame和end frame?他们之间有什么区别?
如果目录不存在,我发现了这种创建目录的方法.但它看起来有点不稳定,我担心这可能会在1000次尝试中出现错误.
if(![[NSFileManager defaultManager] fileExistsAtPath:bundlePath]) {
[[NSFileManager defaultManager] createDirectoryAtPath:bundlePath withIntermediateDirectories:YES attributes:nil error:NULL];
}
Run Code Online (Sandbox Code Playgroud)
只有这个笨拙的方法fileExistsAtPath也可以查找文件,而不仅仅是目录.但对我来说,危险的是:如果这出错怎么办?我该怎么办?保证创建目录的最佳做法是什么,只有在目录不存在时才创建?
我知道文件系统操作永远不会安全.设备可能会在它开始从A到B的位置时突然耗尽电池电量.或者它会偶然发现一个坏位并挂了一秒钟.也许在一些很少的情况下,即使没有目录,它也会返回YES.简单地说:我不相信文件系统操作.
我怎样才能绝对安全?
filesystems objective-c nsfilemanager ios nsdocumentdirectory
我希望我的应用能够将视频上传到Instagram.
Instagram IPhone Hooks提供了如何使用iphone挂钩将照片上传到instagram的信息.我的问题是,是否有人有任何经验,如何完成相同但视频?
ios ×10
objective-c ×6
iphone ×3
swift ×2
uiimageview ×2
uitableview ×2
cocoa-touch ×1
dropdown ×1
filesystems ×1
instagram ×1
ios8 ×1
keyboard ×1
uiimage ×1
uikeyboard ×1
video ×1