在另一个viewController中更新自定义单元格中的进度视图

时间:2014-12-02 06:59:30

标签: ios objective-c

这是我的自定义单元格代码:

#import <UIKit/UIKit.h>

@interface ShareCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UILabel *lblTitle;
@property (strong, nonatomic) IBOutlet UIProgressView *progressView;
@property (strong, nonatomic) IBOutlet UIButton *btnCancel;

@end

如何在视图控制器的自定义单元格中调用更新进度视图事件。谢谢高级

2 个答案:

答案 0 :(得分:2)

我认为你需要以下链接,并在cellforrowatindexpath方法中创建一个UIProgressView。 https://github.com/lightdesign/LDProgressView

答案 1 :(得分:0)

I made a Timer for updating progressView in Cell. you call your method when wants to Update.In viewDidLoad from you want to update progressView.

NSTimer* myTimer = [NSTimer scheduledTimerWithTimeInterval: 10.0 target: self
                                                  selector: @selector(callAfterTenSecond:) userInfo: nil repeats: YES];
[myTimer fire];

That method Gets call.calling method of TableCell.with posting notification.
-(void) callAfterTenSecond:(NSTimer*) t
{
   [[NSNotificationCenter defaultCenter] postNotificationName:@"notificationName" object:_cell];
}
while Creating Cell add observer.
TableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
[cell addObserver];

In tableViewCell.

-(void)addObserver
{
 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(somethingHappens:) name:@"notificationName" object:nil];

 }
 That method gets call when you post notification.
-(void) somethingHappens:(NSNotification*) notification
{
   _progress.progress+=0.1;
 }