zoukankan      html  css  js  c++  java
  • UI小综合+跳转

    效果图

    在storyborad中添加的视图Navigation Controller(把table view的Content设为Static Cells),View Controller(+scroll view),

    文件:

    在BIDViewController.h

    //
    //  BIDViewController.h
    //  scrollView
    //
    //  Created by jxy on 13-4-19.
    //  Copyright (c) 2013年 jxy. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    
    @interface BIDViewController : UIViewController
    @property (weak, nonatomic) IBOutlet UIScrollView *myscrollview;
    
    
    @end

    在BIDViewController.m

    //
    //  BIDViewController.m
    //  scrollView
    //
    //  Created by jxy on 13-4-19.
    //  Copyright (c) 2013年 jxy. All rights reserved.
    //
    
    #import "BIDViewController.h"
    
    @interface BIDViewController ()
    
    @end
    
    @implementation BIDViewController
    @synthesize myscrollview;
    
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        UIImageView *imageViewFirst = nil;
        imageViewFirst = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"kaifeng.tiff"]];
        [imageViewFirst setFrame:CGRectMake(10, 12, 106, 106)];
        [myscrollview addSubview:imageViewFirst];
        
        UILabel *labelTitle = nil;
        labelTitle = [[UILabel alloc]initWithFrame:CGRectMake(126, 12, 184, 36)];
        labelTitle.text = @"开封府";
        labelTitle.font = [UIFont fontWithName:@"Arial" size:30];   //设置内容字体和字体大小
        [myscrollview addSubview:labelTitle];
        
        UIImageView *imageStar = nil;
        imageStar = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"xing.tiff"]];
        [imageStar setFrame:CGRectMake(126, 54, 97, 18)];
        [myscrollview addSubview:imageStar];
        
        UILabel *labelTicket = nil;
        labelTicket = [[UILabel alloc]initWithFrame:CGRectMake(126, 76, 75, 21)];
        labelTicket.text = @"门票 60元";
        labelTicket.font = [UIFont fontWithName:@"Arial" size:17];
        labelTicket.textColor =  [UIColor lightGrayColor];
        [myscrollview addSubview:labelTicket];
        
        UILabel *labelLevel = nil;
        labelLevel = [[UILabel alloc]initWithFrame:CGRectMake(126, 94, 97, 21)];
        labelLevel.text = @"AAAA风景区";
        labelLevel.font = [UIFont fontWithName:@"Arial" size:17];
        labelLevel.textColor =  [UIColor lightGrayColor];
        [myscrollview addSubview:labelLevel];
        
        UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        button1.frame = CGRectMake(10, 126, 300, 44);
        [button1 setTitle:@"导览地图 自动导游" forState:UIControlStateNormal];/////////////看这里
        [button1 addTarget:self action:@selector(btn1p:) forControlEvents:UIControlEventTouchUpInside];
        [myscrollview addSubview:button1];
        
        UIButton *button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        button2.frame = CGRectMake(10, 177, 300, 44);
        [button2 setTitle:@"景点图片 语音解说" forState:UIControlStateNormal];
        [myscrollview addSubview:button2];
        
        UILabel *labelinfo = nil;
        labelinfo = [[UILabel alloc]initWithFrame:CGRectMake(20, 228, 50, 30)];
        labelinfo.text = @"简介";
        labelinfo.font = [UIFont fontWithName:@"Arial" size:25];
        [myscrollview addSubview:labelinfo];
        
        UILabel *textlabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 275, 320, 224)];
        textlabel.text=@"开封古称东京、汴京(亦有大梁、汴梁之称),简称汴,有“十朝古都”、“七朝都会”之称。开封是清明上河图的原创地,有“东京梦华”之美誉,开封是中国优秀旅游城市、全国双拥模范城、全国创建文明城市工作先进城市,也是河南省中原城市群和沿黄“三点一线”黄金旅游线路三大中心城市之一。开封是世界上唯一一座城市中轴线从未变动的都城,城摞城遗址在世界考古史和都城史上是绝无仅有的。北宋东京开封是当时世界最繁华、面积最大、人口最多的大都市。现辖尉氏、杞、通许、兰考、开封五县和鼓楼、龙亭、禹王台、顺河回族、金明五区。";
        textlabel.numberOfLines = 0;
        textlabel.font = [UIFont fontWithName:@"Arial"size:14];//设置字体名字和字体大小
        [myscrollview addSubview:textlabel];
        
        /*UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(0, 275, 320, 224)];
        [textView setText:@"开封古称东京、汴京(亦有大梁、汴梁之称),简称汴,有“十朝古都”、“七朝都会”之称。开封是清明上河图的原创地,有“东京梦华”之美誉,开封是中国优秀旅游城市、全国双拥模范城、全国创建文明城市工作先进城市,也是河南省中原城市群和沿黄“三点一线”黄金旅游线路三大中心城市之一。开封是世界上唯一一座城市中轴线从未变动的都城,城摞城遗址在世界考古史和都城史上是绝无仅有的。北宋东京开封是当时世界最繁华、面积最大、人口最多的大都市。现辖尉氏、杞、通许、兰考、开封五县和鼓楼、龙亭、禹王台、顺河回族、金明五区。"];
        textView.font = [UIFont fontWithName:@"Arial"size:14];//设置字体名字和字体大小
        textView.editable = NO;
        [myscrollview addSubview:textView];*/
        
        UILabel *labelinfo2 = nil;
        labelinfo2 = [[UILabel alloc]initWithFrame:CGRectMake(20, 500, 100, 30)];
        labelinfo2.text = @"旅行贴士";
        labelinfo2.font = [UIFont fontWithName:@"Arial" size:25];
        [myscrollview addSubview:labelinfo2];
        
        UILabel *labelinfo3 = nil;
        labelinfo3 = [[UILabel alloc]initWithFrame:CGRectMake(28, 530, 263, 48)];
        labelinfo3.text = @"市内乘坐1,4,5,8,9,16,20,31路可直达";
        labelinfo3.font = [UIFont fontWithName:@"Arial" size:14];
        [myscrollview addSubview:labelinfo3];
        
        UIButton *button3 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        button3.frame = CGRectMake(10, 580, 300, 44);
        [button3 setTitle:@"地址:河南省开封市鼓楼区包公湖" forState:UIControlStateNormal];
        //button3.alignmentRectInsets [UIEdgeInsetsMake(0, 0, 0, 0)];
        [myscrollview addSubview:button3];
        
        UIButton *button4 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        button4.frame = CGRectMake(10, 630, 300, 44);
        [button4 setTitle:@"电话:0378-39370066" forState:UIControlStateNormal];
        [myscrollview addSubview:button4];
        
        [myscrollview setContentSize:CGSizeMake(320, 680)];
         
    }
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    - (IBAction)btn1p:(id)sender {
        //UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"提示" message:nil delegate:self cancelButtonTitle:@"关闭" otherButtonTitles:nil];
        //[alert show];
        [self performSegueWithIdentifier:@"MytestSegue" sender:self];
    }
    @end

    注意:

    这样就可以在代码中制定这个segue

    源代码:scrollView.zip

    另一个scrollview:ScollView.zip

  • 相关阅读:
    Codeforces Round #368 Div. 2
    TXT文件去除多余空行
    #4247. 串
    #4322. 字符串游戏(strgame)
    #4214. 谢特
    #4155. 咱们去烧菜吧
    #4350. 「十二省联考 2019」字符串问题
    #4349. 「十二省联考 2019」异或粽子
    #4303. 跳蚤
    #4302. 魔法咒语
  • 原文地址:https://www.cnblogs.com/jxyZ/p/3032818.html
Copyright © 2011-2022 走看看