Tag: 客户

如何使用标记属性检查具有自定义单元格的表视图中的多个UISwitch控件的状态

我有一个自定义UITableViewCell的tableview。 Cell有一个UISwitch控件。 我已经添加单元到表视图控制器与所有开关相同的操作。 我在cellForRowAtIndexPath方法中添加了UISwitch标签值。 我想确定什么开关被改变,当用户改变开关状态的开/关。 这里我正在设置UISwitchbutton的操作。 – (void)viewDidLoad { [super viewDidLoad]; cell.switchbtn.userInteractionEnabled=YES; [cell.switchbtn setOn:YES]; [cell.switchbtn addTarget:self action:@selector(switchToggled:) forControlEvents: UIControlEventValueChanged]; [cell.contentView addSubview:cell.switchbtn]; } 这里我正在设置uiswitch的标签值 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellidentifier=@"cellid"; cell=[tableView dequeueReusableCellWithIdentifier:cellidentifier]; if (!cell) { [[NSBundle mainBundle] loadNibNamed:@"cellid" owner:self options:nil]; } cell.switchbtn.tag=indexPath.row; NSLog(@"btn tag=%d",cell.switchbtn.tag); return cell; } 在这里,我打电话给switchToggled:方法来获得uiswitch状态。 – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; […]

POST请求与AFNetworking 2.0不起作用,但在HTTP请求testing器工作

我刚开始使用新的AFNetworking 2.0 API,现在已经使用了以前的版本。 我试图做一个标准的http POST request ,但可悲的是我不太好。 这是我现在的代码: AFHTTPRequestOperationManager *operationManager = [AFHTTPRequestOperationManager manager]; NSDictionary *parameters = @{@"username" : self.usernameField.text, @"password" : self.passwordField.text}; [operationManager POST:@"https:URL GOES HERE" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", [responseObject description]); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error: %@", error); }]; 现在这返回一个JSON的(NULL) ,并没有给我一个像404或什么的状态代码(顺便说一句,我们如何获得使用AFN 2.0时的状态代码?)。 但是,当我尝试使用像apikitchen.com这样的Web应用程序来testingHTTP Post request的信息时,它将工作,当我把用户名和密码在param字段。 所以真的我的问题是,为什么AFN 2.0 parameter […]

如果我嵌套dispatch_async调用会发生什么?

这可能是一个愚蠢的问题,但我需要为自己问清楚。 要将一个块提交到队列以供执行,请使用dispatch_sync和dispatch_async函数。 它们都以队列和块作为参数。 dispatch_async立即返回,asynchronous运行该块,而dispatch_sync阻塞执行,直到提供的块返回。 以下是一些情况: 情况1 dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul); dispatch_async(queue, ^{ [self goDoSomethingLongAndInvolved]; dispatch_async(queue, ^{ NSLog(@"this is statement1"); }); }); 情况2 dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul); dispatch_sync(queue, ^{ [self goDoSomethingLongAndInvolved]; dispatch_sync(queue, ^{ NSLog(@"this is statement1"); }); }); 情况3 { [super viewDidLoad]; dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul); dispatch_async(queue, ^{ [self goDoSomethingLongAndInvolved]; dispatch_sync(queue, ^{ NSLog(@"this […]

是否有可能在2011年以编程方式获得iphone的电话号码?

可能重复: 以编程方式在iPhone OS中获得自己的电话号码 在iOS中获取用户的电话号码仍然是不可能的,并且让你的应用程序接受appStore就像他们在这个线程中所说的:以编程方式在iOS中获得自己的电话号码 ? 我希望自那以后有所改变。 有什么好的select?

Xcode 6.3中的“打开设置”警告问题:“UIApplicationOpenSettingsURLString”的地址与“空指针”的地址比较始终为真

我没有发明轮子。 在iOS8中,从应用程序内部打开设置我正在使用此代码: BOOL canOpenSettings = (&UIApplicationOpenSettingsURLString != NULL); if (canOpenSettings) { NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; [[UIApplication sharedApplication] openURL:url]; } 代码是在很多答案和问题在计算器。 问题出在Xcode 6.3上,我有一个警告说: Comparison of address of 'UIApplicationOpenSettingsURLString' not equal to a null pointer is always true 有趣的是,苹果正在使用它的示例代码: https://developer.apple.com/library/ios/samplecode/AppPrefs/Listings/RootViewController_m.html 关于如何避免警告和仍然检查是否可以打开设置的一些想法?

如何从URL下载文件并存储在文档文件夹中

我创build了一个具有两个页面的应用程序(显示数据列表的第一页和显示详细数据的第二页)。 当点击任何一个单元格时,转到下一页,然后在下一个页面中存在一个button名称:DOWNLOAD,当我点击该button时,该文件将下载并保存到文档文件夹中。 我不知道。 请指导我如何下载任何文件并存储在文档文件夹中。 我在网上search,但我不明白这一点。 请告诉我如何用一个button下载任何文件的代码。 对不起,如果我不好英语。

如何从方法内的块返回variables?

说我有这个方法给定一个URL返回一个UIImage: – (void)getUIImageFromURL:(NSURL *)URL { NSURLRequest *request = [NSURLRequest requestWithURL:URL]; AFHTTPRequestOperation *imageOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; imageOperation.responseSerializer = [AFImageResponseSerializer serializer]; [imageOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { return (UIImage *)responseObject; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { }]; [imageOperation start]; } 但它一直给我这个错误: 向' void(^)(AFHTTPRequestOperation * _strong,__strong id)'参数发送'UIImage *(^)(AFHTTPRequestOperation * __ strong,_ strong id)'的不兼容块​​指针types 我有点新的块,所以也许我完全倒退了。 如何最好的实现这样的方法?

UIRefreshControl与iOS7中的UICollectionView

在我的应用程序中,我使用集合视图的刷新控制。 UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:[UIScreen mainScreen].bounds]; collectionView.alwaysBounceVertical = YES; … [self.view addSubview:collectionView]; UIRefreshControl *refreshControl = [UIRefreshControl new]; [collectionView addSubview:refreshControl]; iOS7有一些令人讨厌的错误,当你拉取集合视图,并且在刷新开始时不松开你的手指时,垂直contentOffset向下移动20-30点,导致难看的滚动跳跃。 如果你在UITableViewController之外使用刷新控制,表格也有这个问题。 但对于他们来说,可以通过将UIRefreshControl实例分配给UITableView的私有属性_refreshControl来轻松解决: @interface UITableView () – (void)_setRefreshControl:(UIRefreshControl *)refreshControl; @end … UITableView *tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds]; [self.view addSubview:tableView]; UIRefreshControl *refreshControl = [UIRefreshControl new]; [tableView addSubview:refreshControl]; [tableView _setRefreshControl:refreshControl]; 但是UICollectionView没有这样的属性,所以必须有一些手动处理它的方法。