Tag: 客观

如何使用button操作(带参数)从自定义UITableViewCell中推送视图

我在自定义单元格中添加了一个button。 它推动了一个观点。 我为CustomTableViewCell.h上的button创build了属性 @property (weak, nonatomic) IBOutlet UIButton *selectedMapButton; 我想使用selectedMapButton在TableViewController.m上推视图我试过这个代码,但是有些东西是不正确的。 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *cord = cellSight[@"S_Coodinates"]; [cell.selectedMapButton addTarget:self action:@selector(sightMapButton:cord) forControlEvents:UIControlEventTouchUpInside]; //When I call sightMapButton method. It gives an error return cell; } – (void)sightMapButton: (NSString *)withCoordinates { TOCGSightseeingMapKitViewController *mapKitController = [[TOCGSightseeingMapKitViewController alloc] init]; mapKitController.sightCoordinates = withCoordinates; [self.navigationController pushViewController:mapKitController animated:YES]; } […]

UIActivityIndi​​catorView不呈现

我有一个应用程序,使Web服务调用来获取数据。 我想添加一个活动指标,当应用程序正在获取Web服务数据时可见。 我已经看了其他职位,虽然我相信我正在做的职位推荐,我的指标不会在屏幕上呈现。 使Web服务调用的对象是stateGauges。 这是我的代码: – (void)viewDidLoad { [super viewDidLoad]; UIActivityIndicatorView *activityStatus = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(120, 230, 50, 50)]; activityStatus.center = self.view.center; [self.view addSubview:activityStatus]; [activityStatus bringSubviewToFront:self.view]; [UIApplication sharedApplication].networkActivityIndicatorVisible = TRUE; [activityStatus startAnimating]; stateGauges = [[GaugeList alloc] initWithStateIdentifier:stateIdentifier andType:nil]; [activityStatus stopAnimating]; } 有什么build议么? 谢谢! V

检测UITableView的自定义单元上的水龙头

所以我有一个自定义的UITableViewCell包含三个UILabel 。 UITableViewCell是这样的UILabel完全覆盖单元格。 现在我想要检测用户每次点击单元格。 问题是因为UILabel覆盖单元格,我不能使用UITableView委托方法来检测单元格上的触摸。 我尽pipe在UILabel上使用手势recoginzers但我没有得到被触摸的单元格的索引。 我也想过在单元格的顶部放置一个透明的button,但这里也有同样的问题,我无法得到被触摸的单元格的索引。 任何人都可以指导我的方法,我怎样才能完成检测与tableView didSelectRowAtIndexPath当UILabel覆盖单元格的水龙头。

drawInRect:withAttributes与“发送到释放实例的消息”

我正在更新iOS 7的应用程序。其中一个变化是切换到新的drawInRect:withAttributes函数,而不是废弃的drawInRect:withFont …这是工作正常的iOS 7testing版,但今天后升级到最新的iOS 7版本,应用程序崩溃就行了: [text drawInRect:theRect withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:fontSz], NSFontAttributeName, color, NSForegroundColorAttributeName, nil]]; 随着消息: *** -[NSStringDrawingTextStorage textContainerForAttributedString:containerSize:lineFragmentPadding:]: message sent to deallocated instance 0x187ed0f0 我尝试运行僵尸工具,这根本没有帮助,在我的代码中既没有分配也没有释放有关的对象。 具体来说,我得到的消息: An Objective-C message was sent to a deallocated 'NSStringDrawingTextStorage' object (zombie) at address: 0x169edc50. 而对象的malloc /释放在调用者之下: [NSStringDrawingTextStorage stringDrawingTextStorage] 我究竟做错了什么?

findUILabel的底部位置,以便可以在下面创build第二个UILabel

我有一个新的文章,我正在创build。 正在为文章标题添加UILabel 。 标题文本有时可能是一行,两行或三行文本。 然后我需要在标题下面创build一个UILabel 。 由于标题具有dynamic高度,因此我无法定位dateUILabel 。 有一个计算来获得我的UILabel的框架的底部位置? 注:我正在使用siteToFit来确保UILabel的框架适合。 // Text UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, self.view.bounds.size.width-20, 50)]; //title.backgroundColor = [UIColor clearColor]; title.backgroundColor = [UIColor redColor]; title.text = self.firstItem.title; //title.text = @"This is a test of a short title that is a little longer"; title.textColor = [UIColor whiteColor]; title.layer.shadowColor = [UIColor blackColor].CGColor; […]

从UITableView保存多个值

我有一个UIViewController调用4 UITableViewControllers作为其子视图。 这些表视图启用了附件复选标记,并可以在表中select多行。 我的问题是,当我的UIViewController与所有的tableview显示,我想保存每个tableview选定的值,并将其保存在一个数组或其他东西。 我也想在另一个类中使用这些选定的值,我必须显示所有这些选定的值。 任何人都可以帮助我如何保存不同tableview的多个值,并在另一个类中使用这些值?

应用程序在删除UITableViewCell后会冻结

当我尝试删除请求的成功块中的UITableViewCell时,出现问题。 在我的 – (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 我正在做AFNetworking的请求 – (NSURLSessionDataTask *)POST:(NSString *)URLString parameters:(id)parameters success:(void (^)(NSURLSessionDataTask *task, id responseObject))success failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure 之后,在成功块我通过closuresSVProgressHUD和删除单元更新UI: NSUserDefaults *usd = [NSUserDefaults standardUserDefaults]; [usd removeObjectForKey:@"payViaCreditCard"]; selectedCardID = nil; [[CreditCardManager sharedCreditCardManager] removeCreditCard:creditCardToDelete]; [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; [self.tableView reloadData]; 最后,我的UI不更新,应用程序冻结,当我重新启动应用程序时,NSUserDefaults中的数据发生了变化。

为每个UITableViewCellpipe理倒数计时器

我必须为每个UITableViewCellpipe理倒数计时器。 随着时间的过去,必须删除那个cell 。 我已经开始实施,但坚持如何删除时间完成的特定cell 。 我的应用程序有多行,但为了演示的目的,我只显示了三行。 我的方法是:在TableViewController.m #import "TableViewController.h" #import "CountdownTimer.h" @interface TableViewController () <CountdownTimerDelegate> @property (nonatomic, strong) NSArray *demoList; @end @implementation TableViewController – (void)viewDidLoad { [super viewDidLoad]; self.demoList = [self dataSource]; } – (NSArray *)dataSource { NSDictionary *demoOne = @{@"DemoId": [NSNumber numberWithInt:1], @"DemoName": @"Timer One", @"DueDate": [[NSDate date] dateByAddingTimeInterval:60]}; NSDictionary *demoTwo = @{@"DemoId": [NSNumber […]

UITableViewCell更改selectedBackgroundView alpha?

我需要更改UITableViewCell的selectedBackgroundView的alpha。 所以我做了以下几点: UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; cell.selectionStyle = UITableViewCellSelectionStyleBlue; UIView *bgView = [UIView new]; bgView.backgroundColor = [UIColor redColor]; bgView.alpha = 0.5;//This setting has no effect cell.selectedBackgroundView = bgView; } 以红色select单元格,但alpha设置对bgView没有影响。

iOS:UICollectionView单元格select不起作用

我有一个UICollectionView作为IB视图层次结构的顶视图。 它利用了一个自定义的布局,沿着视图的左边和右边拆分单元格(从笔尖注册),后面有装饰视图,并在单元格顶部显示整个视图的大小补充视图。 所有这些按预期工作。 什么不起作用的是,select单元格根本就没有被注册。 它们不会触发对collectionView: didSelectItemAtIndexPath:调用正确设置)的调用,也不会在nib工作中突出显示图像的状态。 它performance得更像是一个更高的视angular消耗水龙头,但collectionView是顶视图。 我尝试删除重叠的补充视图和背景装饰视图,也尝试暂时转换为使用stream布局,以防我的自定义布局做了一些棘手的事情 – 仍然没有。 使这更令人沮丧的是我在这个应用程序中的其他视图控制器上使用collectionView(由stream布局治理),他们工作得很好,没有任何特殊的定制。 我没有select,有什么想法?