ios13 購物車優化

2021-09-07 14:33:07 字數 1747 閱讀 6615

//

//03-綜合練習

//#import

"viewcontroller.h

"@inte***ce

viewcontroller ()

//購物車

@property (weak, nonatomic) iboutlet uiview *shopcarview;

//新增按鈕

@property (weak, nonatomic) iboutlet uibutton *addbutton;

//刪除按鈕

@property (weak, nonatomic) iboutlet uibutton *removebutton;

//全域性的下標

//@property (nonatomic, assign) nsinteger index;

@end

@implementation

viewcontroller

- (void

)viewdidload /**

* 新增到購物車

* * @param button 按鈕 */

- (ibaction)add:(uibutton *)button else if (index == 1)else if (index == 2)else if (index == 3)else if (index == 4)else if (index == 5)

*///

方式三 (陣列: (兩個陣列之間沒有任何聯絡,容易出錯))

/*nsarray*imagenames = @[@"danjianbao", @"qianbao", @"liantiaobao", @"shoutibao", @"shuangjianbao", @"xiekuabao"];

nsarray*titlenames = @[@"單肩包", @"錢包", @"鏈條包", @"手提包", @"雙肩包", @"斜挎包"];

// 設定資料

iconview.image = [uiimage imagenamed:imagenames[index]];

titlelabel.text = titlenames[index];

*///

方式四 (陣列 + 字典)

nsarray*dataarr =@[

@,@,

@,@,@,@

];//設定資料

nsdictionary *dict =dataarr[index];

iconview.image = [uiimage imagenamed:dict[@"

icon

"]];

titlelabel.text = dict[@"

name"];

/***********************4.設定按鈕的狀態****************************

*/button.enabled = (index != 5

);

//5.設定刪除按鈕的狀態

self.removebutton.enabled =yes;

}/** * 從購物車中刪除

* * @param button 按鈕 */

- (ibaction)remove:(uibutton *)button

*/self.removebutton.enabled = (self.shopcarview.subviews.count != 0

);

}@end

ios13 購物車優化

03 綜合練習 import viewcontroller.h inte ce viewcontroller 購物車 property weak,nonatomic iboutlet uiview shopcarview 新增按鈕 property weak,nonatomic iboutlet u...

13 購物車系統

1.設計表 1.使用者表 create table users id int primary key,name varchar 64 not null default pwd char 32 not null default 因為密碼是md5儲存,md5儲存後有32個字元 email varchar...

購物車(註冊 登入 購物 購物車 結帳)

購物車 註冊 登入 購物 購物車 結帳 shopping car dict dict money 0 def input username pwd username input username pwd input pwd return username,pwd def goods get with...