小编Shr*_*hri的帖子

如何检测UITableViewCellStyleSubtitle样式中UITableViewCell对象的UIImageView上的触摸

我正在使用 样式中的UITableViewCell对象UITableViewCellStyleSubtitle(即左侧的图像视图,粗体的文本标签以及详细文本标签下的文本标签)来创建我的表格.现在我需要检测触摸UIImageView并且还要知道单击图像视图的索引路径/单元格.我试过用

cell.textLabel.text = @"Sometext";
NSString *path = [[NSBundle mainBundle] pathForResource:@"emptystar1" ofType:@"png"];
UIImage *theImage = [UIImage imageWithContentsOfFile:path];
cell.imageView.image = theImage;
cell.imageView.userInteractionEnabled = YES; 
Run Code Online (Sandbox Code Playgroud)

但它不起作用.每当点击图像时,都会didSelectRowAtIndexPath:被调用.我不想创建一个单独的UITableViewCell并添加自定义按钮.有没有办法检测UIImageView自己的触摸?

cocoa-touch objective-c uitableview uiimageview

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

在快速枚举中跟踪索引

我想在使用快速枚举时得到当前对象的索引,即

for (MyClass *entry in savedArray) {
// What is the index of |entry| in |savedArray|?
}
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c fast-enumeration

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

如何将UIImagePickerController添加为子视图而不是Modal View

我的一个视图上有一个段控制器,现在在段控制器的第0个索引上我想通过添加子视图而不是ModalViewController来添加UIImagePickerController(用于向用户显示摄像头视图).现在视图已加载,但它不显示任何摄像机视图.我能够通过presentModalViewController显示摄像机视图并传递其对象.

这是代码 -

if(segmentedControl.selectedSegmentIndex==0)

{

UIImagePickerController *cameraView = [[UIImagePickerController alloc] init];

cameraView.sourceType = UIImagePickerControllerSourceTypeCamera;

cameraView.showsCameraControls = NO;

//[self presentModalViewController:cameraView animated:YES]; //Working

[self.view addSubview:cameraView.view]; // Not Working

}
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uiimagepickercontroller

5
推荐指数
1
解决办法
5517
查看次数

可以在运行时使用Objc/iPhone代码对xsd验证xml

我有运行时读入的xml文件,是否可以在运行时使用Obj C ??对xsd文件验证xml?这可以在javac#中完成.但我需要在我的iPhone应用程序中运行它.

xml iphone cocoa-touch xsd objective-c

5
推荐指数
1
解决办法
2767
查看次数

可以在MKMapView上绘制的最大注释数(MKAnnotation)?

我想在mapview上添加一些注释(arround 500),但它似乎显示的最大值为100.如果我超过100,则不会调用viewForAnnotation委托方法.但它适用于100以下的注释.

这是代码:(仅当annotationArray数组的数量小于101 时才有效)

_allPoints = [[NSMutableArray alloc] init];

NSString* responseFile = [[NSBundle mainBundle] pathForResource:@"Datafile" ofType:@"txt"];
NSData *sampleData = [NSData dataWithContentsOfFile:responseFile];  
if (sampleData) {  
    NSError* error;
    NSDictionary* json = [NSJSONSerialization 
                          JSONObjectWithData:sampleData

                          options:kNilOptions 
                          error:&error];

    NSArray* response = [json objectForKey:@"response"];
    for (NSDictionary *lineDict in response) {
        if ([[lineDict objectForKey:@"data"] isKindOfClass:[NSArray class]]) {
            SinglePoint *singlePoint = [[SinglePoint alloc] initWithDictionary:lineDict];
            [_allPoints addObject:singlePoint];
        }
        else {
            NSLog(@"Error");
        }
    }
}  


_mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[_mapView setDelegate:self];
[self.view …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c mkmapview mkannotation ios

5
推荐指数
1
解决办法
4124
查看次数

如何同步调用NSStream

如何同步调用NSStream以获得结果?

目前,我正在其中一个委托方法中获得异步回调

 `(void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent`- 
Run Code Online (Sandbox Code Playgroud)

iphone ftp asynchronous objective-c nsstream

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

Google Feed api与iPhone/Objective C集成

我正在构建一个RSS阅读器.一些现有的(例如,iPhone/iPad的Pulse News)有一个搜索框,您可以搜索某个术语(例如"体育"),它将返回符合您搜索条件的供稿列表.所以在这个例子中,你输入"sports",然后搜索,然后回到ESPN.com的新闻源,Yahoo!体育'新闻提要等

经过初步研究,我发现Google Feed API也是如此. https://code.google.com/intl/fr/apis/ajaxfeeds/documentation/reference.html#findFeeds

但是,我无法弄清楚如何使用谷歌饲料api.它返回我需要解析的xml,但我感到困惑的部分是如何调用API以及在哪里捕获xml响应.有人可以发布一个教程或一些如何集成它的帮助.

iphone rss search objective-c google-feed-api

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

将Array保存到包含自定义对象iPhone的Plist文件

我有一个名为XYZ的类继承自NSObject和一个包含XYZ对象的数组.我需要将此数组写入文档目录中的plist文件.在尝试[array writeToFile ....]后,我发现writeToFile失败,因为该数组包含XYZ类的自定义对象.

可能的解决方案是将对象转换为NSData.有什么不同的方法来实现这一目标?我发现NSCoding很合适,但无法理解如何使用它.任何帮助将不胜感激.

iphone cocoa-touch objective-c ios nsdocumentdirectory

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