我正在使用
样式中的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
自己的触摸?
我想在使用快速枚举时得到当前对象的索引,即
for (MyClass *entry in savedArray) {
// What is the index of |entry| in |savedArray|?
}
Run Code Online (Sandbox Code Playgroud) 我的一个视图上有一个段控制器,现在在段控制器的第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) 我想在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) 如何同步调用NSStream以获得结果?
目前,我正在其中一个委托方法中获得异步回调
`(void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent`-
Run Code Online (Sandbox Code Playgroud) 我正在构建一个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响应.有人可以发布一个教程或一些如何集成它的帮助.
我有一个名为XYZ的类继承自NSObject和一个包含XYZ对象的数组.我需要将此数组写入文档目录中的plist文件.在尝试[array writeToFile ....]后,我发现writeToFile失败,因为该数组包含XYZ类的自定义对象.
可能的解决方案是将对象转换为NSData.有什么不同的方法来实现这一目标?我发现NSCoding很合适,但无法理解如何使用它.任何帮助将不胜感激.
objective-c ×8
iphone ×6
cocoa-touch ×4
ios ×2
asynchronous ×1
ftp ×1
mkannotation ×1
mkmapview ×1
nsstream ×1
rss ×1
search ×1
uiimageview ×1
uitableview ×1
xml ×1
xsd ×1