小编app*_*eak的帖子

如何在UITableView中设置表头的高度?

我已经浏览了有关UITableView类和委托引用的Apple文档,但无法找到明确设置表头高度的方法.

我使用以下委托设置表格单元格高度:

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)

并使用以下代理设置节标题/页脚高度.

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
Run Code Online (Sandbox Code Playgroud)

谁能帮我设置表格页眉/页脚高度?

谢谢.

iphone uitableview

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

iOS:为什么我不能将nil设置为NSDictionary值?

这可能是一个非常基本的问题,但我想知道为什么我不能将nil指定为NSDictionary值?我在我的代码中有很多地方.如果[q objectForKey:@"text"]是零,那么App正在崩溃.

NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:2];
[dict setObject:[q objectForKey:@"text"] forKey:@"text"];
Run Code Online (Sandbox Code Playgroud)

在将其分配给字典之前,我必须检查无处不在的nil.这是唯一正确的做法吗?我错过了一些明显的东西吗

if([q objectForKey:@"text"] != nil)
    [dict setObject:[q objectForKey:@"text"] forKey:@"text"];
else
    [dict setObject:@"" forKey:@"text"];
Run Code Online (Sandbox Code Playgroud)

iphone null nsdictionary ios

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

iOS:保存为PNG表示数据后,图像旋转90度

我已经研究了足够的工作,但无法修复它.只要我将图像存储为UIImage,从相机拍照后,它就可以了,但只要我将此图像存储为PNG表示,它就会旋转90度.

以下是我的代码和我尝试过的所有事情:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{
    NSString *mediaType = [info valueForKey:UIImagePickerControllerMediaType];

    if([mediaType isEqualToString:(NSString*)kUTTypeImage]) 
    {
        AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
        delegate.originalPhoto  = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
        NSLog(@"Saving photo");
        [self saveImage];
        NSLog(@"Fixing orientation");
        delegate.fixOrientationPhoto  = [self fixOrientation:[UIImage imageWithContentsOfFile:[delegate filePath:imageName]]];      
        NSLog(@"Scaling photo");
        delegate.scaledAndRotatedPhoto  =  [self scaleAndRotateImage:[UIImage imageWithContentsOfFile:[delegate filePath:imageName]]];
    }
    [picker dismissModalViewControllerAnimated:YES];
    [picker release];
}


- (void)saveImage
{
    AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    NSData *imageData = UIImagePNGRepresentation(delegate.originalPhoto);
    [imageData writeToFile:[delegate filePath:imageName] atomically:YES];
}
Run Code Online (Sandbox Code Playgroud)

这里分别从这里这里取得fixOrientation和scaleAndRotateImage函数.当我在UIImage上应用它们时,它们工作正常并旋转图像,但如果我将图像保存为PNG表示并应用它们则不起作用.

请执行以上功能后请参考以下图片:

第一张照片是原始的,第二张是保存的,第三张和第四张是在保存的图像上应用fixorientation和scaleandrotate功能后

iphone image-rotation uiimage landscape-portrait ios5.1

38
推荐指数
4
解决办法
4万
查看次数

iPhone:在生产证书上推送通知测试

我有一个快速的问题.我一直在测试我的iPhone应用程序的开发推送通知证书,并且它一直正常工作.我只想知道在将应用程序提交到AppStore之前是否可以测试生产证书?我尝试过,但是当我使用生产证书时,消息不会出现.当我使用生产证书时,Apple是否要求应​​用程序在AppStore中?

谢谢.

production-environment apple-push-notifications ios

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

iOS:无法启动.app文件

我不知道为什么它在我的.app文件中寻找目录.每次我运行应用程序时,它都会在iPhone上安装应用程序但不运行并给出以下错误.谁能告诉我这个设置存储在哪里?谢谢.

error: failed to launch '/Users/xxx/Library/Developer/Xcode/DerivedData/MyApp- ccbvvzjjzvwuerchrpulknxtenoq/Build/Products/Debug-iphoneos/MyApp.app/MyApp' -- No such file or directory (/Users/xxx/Library/Developer/Xcode/DerivedData/MyApp-ccbvvzjjzvwuerchrpulknxtenoq/Build/Products/Debug-iphoneos/MyApp.app/MyApp)
Run Code Online (Sandbox Code Playgroud)

iphone launching-application .app ios5.1

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

将图像添加到UIBarButtonItem按钮

我使用以下代码将UITabButtonItem添加到我的视图控制器上.任何人都可以告诉我它是否可以将图像与它联系起来?

UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(favouriteButtonClicked:)]; 
viewController2.navigationItem.rightBarButtonItem = button; 
[button release];
[self.navigationController pushViewController:viewController2 animated:YES];
Run Code Online (Sandbox Code Playgroud)

我在其他地方使用以下代码,但在上面的代码我将viewcontroller推到我当前的视图,这段代码不起作用.我不得不使用上面的代码.

UIButton *button =  [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"unselected.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(favouriteButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
[button setFrame:CGRectMake(280, 25, 30, 30)];
viewController2.navigationController.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease];

[self.navigationController pushViewController:viewController2 animated:YES];
Run Code Online (Sandbox Code Playgroud)

我不知道有什么问题但是当我用initWithBarButtonSystemItem替换这个自定义按钮代码时,它工作得很好!!!

最后,我整理出这个问题,并张贴在这里工作的代码,但仍,如果我有在baseviewcontroller一个按钮,我不明白,我添加它,就象下面,这是行不通的!我必须在viewwillappear中使用我接受的答案中给出的代码!

    [favButton addTarget:self action:@selector(favouriteButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
     self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease];  
Run Code Online (Sandbox Code Playgroud)

以下代码仍然无法正常工作!不知道发生了什么.

MPMoviePlayerViewController *videoController = [[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:filePath]] autorelease];

UIButton* favouritebutton =  [UIButton buttonWithType:UIButtonTypeCustom];
[favouritebutton setBackgroundImage:[UIImage imageNamed:@"unselected.png"] forState:UIControlStateNormal];
[favouritebutton addTarget:self action:@selector(favouriteButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
[favouritebutton …
Run Code Online (Sandbox Code Playgroud)

iphone image uibarbuttonitem

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

iPhone:NSUserDefaults存储在哪里?

我可以使用NSUserDefaults存储,检索和删除值.我无法找到NSUserDefaults在iPhone上物理存储的位置?我想它应该是plist文件但不确定.有谁知道它是否有可能在iPhone上看到这个值?

谢谢.

iphone nsuserdefaults

12
推荐指数
2
解决办法
8825
查看次数

iOS:使用self和下划线(_)和变量

可能重复:
cocoa objective-c类中变量前面的下划线如何工作?

在合成它之后,我一直很困惑使用自变量或带有变量名的下划线,如下所示:

In .h file:
@property(nonatomic, strong) NSMutableArray *users;

In .m file:
@synthesize users = _users;
Run Code Online (Sandbox Code Playgroud)

基于我在使用self.users时的理解,操作系统将确保在set方法中释放以前分配的内存,因此我们不需要明确注意.

_users是用户的实例变量,通常在访问users变量时使用.如果我使用_users更改它的值,那么它将不会触发KVO委托,它不会通知观察用户值变化的类.

此外,self.users允许在方法名称中区分虚拟变量,如下所示,

- (void)assignUsers:(NSMutableArray*)users {
      self.users = users;
}
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我,在使用_users或self.users时,是否有任何我理解错误或遗漏的内容.谢谢.

memory-management objective-c self ios

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

网络摄像机通过有线通信传输到iPad2的摄像机

我想开发一个需要在网络摄像头类型摄像机和iPad2之间进行有线通信的应用程序.基本上我会使用电缆直接连接网络摄像头和iPad2,当我启动网络摄像头时,网络摄像头拍摄的任何图像(图片/视频)都应显示在iPad2上.

根据我对此的研究,我发现iPad2线缆只是为iPod编程而制作的,因此连接器不是传统的USB端口,我无法在网络摄像头和iPad2之间进行直接通信.我错过了什么吗?

我们将使用Vivotek相机,他们在这里提到我们可以使用safari来接收Motion-JPEG流.我想知道这是否也可能在iPad 2上,它是否可靠?

此外,我发现Apple的MFi计划开发了连接iPod,iPhone和iPad的电子配件.有没有人在这里使用过这个,如果我能为此而知道更多关于这一点的信息呢?

谢谢.

webcam communication objective-c ios ipad-2

8
推荐指数
1
解决办法
2390
查看次数

Xcode与iPhone 4开发:可执行文件使用无效的权利签名.

完整的错误消息是:

可执行文件使用无效的权利进行签名.

可执行文件使用无效的权利进行签名.应用程序的代码签名权利文件中指定的权利与您的供应配置文件中指定的权利不匹配.(0xE8008016).

我已经花了几个小时来解决此错误消息但尚未解决它.基本上,我已将iPhone-4.0用于开发,并在developer.apple.com上从我的帐户安装了有效的配置文件.

我们有我们的主要应用程序,它使用相同的配置文件签名,并且工作正常,但是当我尝试运行http://teachyourselfiphone.com/书中给出的应用程序用于学习和测试时,它只是不起作用.

我已经尝试了以下所有方面,但没有任何作用.

  1. 可执行文件使用无效的权利进行签名
  2. http://jomnius.blogspot.com/2010/11/executable-was-signed-with-invalid.html

有人可以帮我摆脱这个吗?

xcode ios4 ios provisioning-profile ios-provisioning

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