//tableviewXibweb
@interface ViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>ide
@property (weak, nonatomic) IBOutlet UITableView *tableview;atom
@property(nonatomic,strong)NSString *string;url
@property(nonatomic,strong)NSDictionary *dict;spa
@end .net
- (void)viewDidLoad {3d
[super viewDidLoad];代理
_tableview.delegate =self;orm
_tableview.dataSource = self;對象
_dict = @{@"百度":@"https://www.baidu.com",@"騰訊":@"https://www.qq.com",@"新浪":@"https://www.sina.com"};
[self.view addSubview:_tableview];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [[_dict allKeys] count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if(cell == nil){
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}
cell.textLabel.text = [_dict allKeys][indexPath.row];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
_string = [_dict allValues][indexPath.row];
[self performSegueWithIdentifier:@"xian" sender:nil];
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:@"xian"]){
id send = segue.destinationViewController;
[send setValue: _string forKey:@"string"];
}
}
@interface Viewsen : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *label;
@property (weak, nonatomic) IBOutlet UIButton *button;
@property(nonatomic,strong)NSString *string;
@property(nonatomic,strong)NSDictionary *dict;
@end
- (void)viewDidLoad {
[super viewDidLoad];
[_button setTitle:@"返回" forState:UIControlStateNormal];
UIWebView *web=[[UIWebView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
NSURL *url=[NSURL URLWithString:_string];
[web loadRequest:[NSURLRequest requestWithURL:url]];
[_button bringSubviewToFront:web];
[self.view addSubview:web];
[self.view addSubview:web];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//ScollView
//對圖片進行縮放:首先設置ScrollView,注意ScrollView只是容器,滾動或縮放的都是其中的控件當內部的控件比scrollView大才能夠進行縮放或拖拽的。
//設置ScrollView的contentSize
//遵照協議
//設置代理對象
//設置將要縮放的控件(協議方法)
//設置最大/最小縮放比例
//縮放捏合的手勢需按下option
- (void)viewDidLoad {
[super viewDidLoad];
_viewOfScroll.delegate=self;//設置代理對象
_viewOfScroll.contentSize=_image.frame.size;//設置ScrollView的滾動的大小
_viewOfScroll.maximumZoomScale=3;//設置放大的倍數
_viewOfScroll.minimumZoomScale=0.4;//設置縮小的倍數
}
//設置將要被縮放的控件
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
return _image;
}
//拖拽結束回調方法
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
NSLog(@"拖拽了");
}
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *textFeild;
- (IBAction)chuanzhi:(id)sender;
- (IBAction)chuanzhi:(id)sender {
NSUserDefaults *userDefault=[NSUserDefaults standardUserDefaults];
[userDefault setValue:_textFeild.text forKey:@"lable"];
[userDefault synchronize];
}
@interface twoPage : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *labelInTwo;
@implementation twoPage
-(void)viewDidLoad{
[super viewDidLoad];
NSUserDefaults *userDefault=[NSUserDefaults standardUserDefaults];
_labelInTwo.text=[userDefault valueForKey:@"lable"];
}