【发布时间】:2016-04-12 10:47:58
【问题描述】:
我正在开发一个 watchkit 应用程序,我有一个表视图,它必须具有删除行的功能。我看到了一个使用内容菜单的教程。但不知道如何从表中删除行。请帮帮我。
#import "HomeInterfaceController.h"
#import "HomeTableRowController.h"
#import "DetailHomeInterfaceController.h"
@interface HomeInterfaceController ()
@property (unsafe_unretained, nonatomic) IBOutlet WKInterfaceTable *homeTable;
@property (nonatomic,strong) NSArray *nameArr;
@end
@implementation HomeInterfaceController
- (void)awakeWithContext:(id)context {
[super awakeWithContext:context];
self.nameArr = [NSArray arrayWithObjects: @"Jill Valentine", @"Peter Griffin", @"Meg Griffin", @"Jack Lolwut",
@"Mike Roflcoptor", @"Cindy Woods", @"Jessica Windmill", @"Alexander The Great",
@"Sarah Peterson", @"Scott Scottland", @"Geoff Fanta", @"Amanda Pope", @"Michael Meyers",
@"Richard Biggus", @"Montey Python", @"Mike Wut", @"Fake Person", @"Chair",
nil];
[self setupTable];
// Configure interface objects here.
}
- (void)willActivate {
// This method is called when watch view controller is about to be visible to user
[super willActivate];
}
- (void)didDeactivate {
// This method is called when watch view controller is no longer visible
[super didDeactivate];
}
- (void)setupTable {
[self.homeTable setNumberOfRows:[self.nameArr count] withRowType:@"HomeTableRowController"];
for (NSInteger i = 0; i < self.nameArr.count; i++)
{
HomeTableRowController *row = [self.homeTable rowControllerAtIndex:i];
NSString *thisBook = [self.nameArr objectAtIndex:i];
[row.reminderHeadlineLabel setText:thisBook];
// [row.imageRow setImage:[UIImage imageNamed:@"abc.jpg"]];
}
}
- (void)table:(WKInterfaceTable *)table didSelectRowAtIndex:(NSInteger)rowIndex
{
NSDictionary *d=[NSDictionary dictionaryWithObject:@"hi" forKey:@"nm"];
[self presentControllerWithName:@"DetailHome" context:d];
}
- (IBAction)deleteButtonAction {
}
@end
【问题讨论】:
-
你能添加你已经完成的代码并更具体吗?
-
我没有做太多@Shrolox
-
首先尝试用单元格实现表格视图,然后如果您显示代码和特定问题,也许社区将能够帮助您。有很多关于在 objC 中创建 tableview 的教程。例如这里:swiftiostutorials.com/watchkit-tutorial
-
Shrolox 我已经实现了这个,我现在正在寻找如何删除行...
-
哦,对不起,我误解了你:/你能发布你的代码,以便我调整我的答案吗?
标签: objective-c iphone xcode7 watchkit