日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

对简单单元格的增删改

發布時間:2025/4/14 编程问答 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 对简单单元格的增删改 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

效果圖

?

?

?

?

?

?

?

?

?

?

?

?

?

?

#import <UIKit/UIKit.h>#import "RootTableViewController.h"@interface AppDelegate : UIResponder <UIApplicationDelegate>@property (strong, nonatomic) UIWindow *window;@end

?

?

#import "AppDelegate.h"@interface AppDelegate ()@end@implementation AppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {self.window.rootViewController=[[UINavigationController alloc]initWithRootViewController:[[RootTableViewController alloc]initWithStyle:UITableViewStylePlain]];return YES; }

?

?

#import <UIKit/UIKit.h>@interface RootTableViewController : UITableViewController@property(strong,nonatomic) NSMutableArray * array;@end

?

?

#import "RootTableViewController.h" #import "ViewController.h" @interface RootTableViewController ()<postValuedelegate> {//記錄選中行的索引值NSIndexPath * currentInfrxPath; } @end@implementation RootTableViewController- (void)viewDidLoad {[super viewDidLoad];//添加liftbarabuttonself.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addItem)];self.navigationItem.rightBarButtonItem = self.editButtonItem;self.array=[NSMutableArray array];[self.array addObject:@"zhangsan"];[self.array addObject:@"lisi"];[self.array addObject:@"wangwu"];[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"reuseIdentifier"];// Uncomment the following line to preserve selection between presentations.// self.clearsSelectionOnViewWillAppear = NO;// Uncomment the following line to display an Edit button in the navigation bar for this view controller.}-(void)addItem {UIAlertController *alertcontroller=[UIAlertController alertControllerWithTitle:@"確定要增加嗎" message:@"輸入姓名?" preferredStyle:(UIAlertControllerStyleAlert)];UIAlertAction * ok=[UIAlertAction actionWithTitle:@"增加" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {UITextField * textName= alertcontroller.textFields[0];[self.array addObject:textName.text];[self.tableView reloadData];// NSLog(@"真正的操作");}];[alertcontroller addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {textField.placeholder=@"添加姓名";}];[alertcontroller addAction:ok];[self presentViewController:alertcontroller animated:YES completion:nil];}-(void)postvalue:(NSString *)username {//為集合指定索引位置元素賦值self.array[currentInfrxPath.row]=username;NSLog(@"%@",username);//刷新數據[self.tableView reloadData]; }- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated. }#pragma mark - Table view data source- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {return 1; }- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {return self.array.count; }- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier" forIndexPath:indexPath];cell.textLabel.text=self.array[indexPath.row];return cell; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {currentInfrxPath=indexPath;ViewController *vc=[[ViewController alloc]init];vc.name=self.array[indexPath.row];vc.delegate=self;[self.navigationController pushViewController:vc animated:YES]; }// Override to support conditional editing of the table view. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {// Return NO if you do not want the specified item to be editable.return YES; }// Override to support editing the table view. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {if (editingStyle == UITableViewCellEditingStyleDelete) {// Delete the row from the data source[self.array removeObjectAtIndex:currentInfrxPath.row];[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];} else if (editingStyle == UITableViewCellEditingStyleInsert) {// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view} }// Override to support rearranging the table view. - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {//1.找到指定位置集合元素NSString * name= self.array[fromIndexPath.row];//2.刪除集合元素[self.array removeObject:name];//3插入集合[self.array insertObject:name atIndex:toIndexPath.row];NSLog(@"%@",self.array);}// Override to support conditional rearranging of the table view. - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {// Return NO if you do not want the item to be re-orderable.return YES; }/* #pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {// Get the new view controller using [segue destinationViewController].// Pass the selected object to the new view controller. } */@end

?

?

#import <UIKit/UIKit.h>@protocol postValuedelegate <NSObject>-(void)postvalue:(NSString *) username;@end@interface ViewController : UIViewController<UITextFieldDelegate>@property(strong,nonatomic) NSString *name;@property(strong,nonatomic) UITextField * textNmae;@property(strong,nonatomic) id<postValuedelegate> delegate;@end

?

?

#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];self.view.backgroundColor=[UIColor greenColor];self.textNmae=[[UITextField alloc]initWithFrame:CGRectMake(100, 100, 150, 44)];self.textNmae.delegate=self;self.textNmae.borderStyle=1;self.textNmae.text=self.name;[self.view addSubview:self.textNmae]; }-(BOOL)textFieldShouldReturn:(UITextField *)textField {if (self.delegate) {[self.delegate postvalue:textField.text];}if ([textField isFirstResponder]) {[textField resignFirstResponder];}[self.navigationController popViewControllerAnimated:YES];return YES; } - (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated. }@end

?

轉載于:https://www.cnblogs.com/fume/p/5293015.html

總結

以上是生活随笔為你收集整理的对简单单元格的增删改的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美v在线 | 97视频| 中文字幕丝袜诱惑 | 成人影片在线免费观看 | 欧美高大丰满少妇xxxx | 91成人精品视频 | 在线亚洲色图 | 激情综合视频 | 欧美在线观看免费高清 | 亚洲精品第五页 | 日韩精品一线二线三线 | 免费看黄色漫画 | 嫩草影院中文字幕 | 国产黄视频在线观看 | 国产精品99re | 啊av在线 | 国产乱色精品成人免费视频 | 亚洲精品少妇一区二区 | 99热这里都是精品 | 午夜美女福利 | 亚洲一线在线观看 | 蜜桃导航-精品导航 | 国产午夜精品久久久久久久 | 中文字幕在线观看精品 | 欧美三级在线观看视频 | 无码国产精品久久一区免费 | 男生和女生一起差差差很痛的视频 | 国产乱码精品一区二三区蜜臂 | 国产奶头好大揉着好爽视频 | 国产网站视频 | 5d肉蒲团之性战奶水 | 国产欧美日韩一区二区三区 | 中文字幕一区二区三区四区欧美 | 久久久久国产精品一区二区 | 少妇高潮久久久 | 欧美在线你懂的 | 国产日韩欧美日韩大片 | www.一区二区三区 | 黄网在线| 视频在线观看网站免费 | 超碰人人干人人 | 91区 | 在线 日本 制服 中文 欧美 | 欧美一级二级在线观看 | 波多野结衣不卡视频 | 久久人人爱 | 免费污网站在线观看 | 日本三级视频在线播放 | 日本xxxx高清 | 乱图区| h片在线观看 | 9.1在线观看免费 | 日本边添边摸边做边爱 | 国产第一草草影院 | 热久久这里只有精品 | 鲁鲁狠狠狠7777一区二区 | 办公室大战高跟丝袜秘书经理ol | 成人免费在线观看网站 | 国产日韩欧美成人 | 日本在线三级 | 九九热精品在线 | 在线观看sm| 欧美高清视频一区二区 | 国产高清免费在线 | 天天草比 | 亚洲视频在线免费 | 在线播放无码后入内射少妇 | 国产午夜精品久久 | 国产一区欧美二区 | 天天射天天色天天干 | 无码免费一区二区三区免费播放 | 91红桃视频 | 毛片一区 | 欧美一区二区福利视频 | 国产丝袜网站 | 少妇被中出 | 在线观看欧美日韩 | 亚洲国产激情 | 一区二区不卡视频在线观看 | 亚洲风情亚aⅴ在线发布 | 国产男人搡女人免费视频 | 黄色片在哪里看 | 国产精品久久综合青草亚洲AV | 91免费网站在线观看 | 人妻精品一区一区三区蜜桃91 | 熟女视频一区二区三区 | 免费观看一区二区三区 | 超碰青娱乐 | 国产一区二区毛片 | 国产美女喷水视频 | 四虎永久在线 | 午夜亚洲福利在线老司机 | 97超碰在线播放 | 在线观看免费高清 | 久久美 | 六月丁香啪啪 | 日韩欧洲亚洲 | 精品夜夜澡人妻无码av | 亚洲免费av网 |