#pragma mark –内容
(标记方法的方法)
蓝色弹窗
UIAlertView * Alert =[[UIAlertView alloc]initWithTitle:@"提示"message:@"请输入用户名和密码" delegate:self cancelButtonTitle:@"取消"otherButtonTitles:@"确定", nil];
[Alert show];
字符串对比
if ([UserNumber.textisEqualToString:@"lebo"]&&[UserPassword.textisEqualToString:@"123456"] ) {
NSLog(@"成功");
}
返回按钮
-(void)addViewAction
{
UIButton * BackBtn =[UIButton buttonWithType:UIButtonTypeCustom];
BackBtn.frame =CGRectMake(0,5,55, 30);
[BackBtn setImage:[UIImage imageNamed:@"返回(1).png"] forState:UIControlStateNormal];
[BackBtn setImage:[UIImage imageNamed:@"返回(2).png"] forState:UIControlStateHighlighted];
[BackBtn addTarget:self action:@selector(BackBtnAction)forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem =[[UIBarButtonItemalloc]initWithCustomView:BackBtn];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self addViewAction];
//在UITextField输入内容,点击空白处收起键盘的方法
- (void)touchesBegan:(NSSet *)toucheswithEvent:(UIEvent *)event
{
// 前面是textfield名
[UserNumber resignFirstResponder];
[UserPassword resignFirstResponder];
}
增加监听,当键盘出现或改变时调用的方法
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
增加监听,当键盘退出时调用的方法
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
键盘出现或改变时调用的具体方法
- (void)keyboardWillShow:(NSNotification*)aNotification
{
获取键盘高度
NSDictionary *userInfo = [aNotification userInfo];
NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyboardRect = [aValue CGRectValue];
CGFloat height = keyboardRect.size.height;
CGSize size =self.view.frame.size;
[UIView animateWithDuration:0.5 animations:^{
self.view.frame =CGRectMake(0, -height,size.width, size.height);
}];
}
键盘退出时调用的具体方法
- (void)keyboardWillHide:(NSNotification*)aNotification
{
CGSize size =self.view.frame.size;
[UIView animateWithDuration:0.5 animations:^{
self.view.frame =CGRectMake(0,0,size.width, size.height);
}];
}
布尔键值池
[[NSUserDefaults standardUserDefaults] setBool:NOforKey:@"Pltitle"];
获取字体的规格
NSString * Str =[PicNameArrayobjectAtIndex:indexPath.row];
CGSize size = [Str sizeWithFont:[UIFont systemFontOfSize:18]constrainedToSize:CGSizeMake(276.0f, 300.0f)lineBreakMode:UILineBreakModeWordWrap];
viewWillAppear:
Called when the view is about to madevisible. Default does nothing
视图即将可见时调用。默认情况下不执行任何操作
viewDidAppear:
Called when the view has been fullytransitioned onto the screen. Default does nothing
视图已完全过渡到屏幕上时调用
viewWillDisappear:
Called when the view is dismissed, coveredor otherwise hidden. Default does nothing
视图被驳回时调用,覆盖或以其他方式隐藏。默认情况下不执行任何操作
viewDidDisappear:
Called after the view was dismissed,covered or otherwise hidden. Default does nothing
视图被驳回后调用,覆盖或以其他方式隐藏。默认情况下不执行任何操作
loadView;
This is where subclasses should createtheir custom view hierarchy if they aren't using a nib. Should never be calleddirectly.
这是当他们没有正在使用nib视图页面,子类将会创建自己的自定义视图层。绝不能直接调用。
viewDidLoad;
Called after the view has been loaded. Forview controllers created in code, this is after -loadView. For view controllersunarchived from a nib, this is after the view is set.
在视图加载后被调用,如果是在代码中创建的视图加载器,他将会在loadView方法后被调用,如果是从nib视图页面输出,他将会在视图设置好后后被调用。
定义图片名字为变量的方法
for (int i=0; i<3; i++)
{
NSString * ImageName =[[NSStringalloc]initWithFormat:@"sharepic%d",i+1];
UIImageView * LogoImage =[[UIImageView alloc]initWithImage:[UIImageimageNamed:ImageName]];
}
电话
- (IBAction)IBActionThree:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURLURLWithString:@"tel://10086"]];
}
访问主页
- (IBAction)IBActionOne:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURLURLWithString:@"http://www.wlantv.cn"]]
;
}
APPstore打分
- (IBAction)IBActionTwo:(id)sender {
NSString *str = [NSString stringWithFormat:
@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%d",
m_appleID ];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}
tableview grouped 模式的相关设置
// 模块数
-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView
{
return 2;
}
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
if (section==0) {
return [picArray count];
}
else{
return [pic2Array count];
}
}
// 向cell中添加内容
-(UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [NSStringstringWithFormat:@"Cell"];
UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
for (UIImageView * Image1view in cell.contentView.subviews) {
[Image1view removeFromSuperview];
}
for (UILabel * Label in cell.contentView.subviews) {
[Label removeFromSuperview];
}
if (indexPath.section==0) {
UIImageView * Image1View =[[UIImageViewalloc]initWithFrame:CGRectMake(10, 7, 25, 25)];
Image1View.image = [picArray objectAtIndex:indexPath.row];
[cell.contentView addSubview:Image1View];
UILabel * Label =[[UILabel alloc]initWithFrame:CGRectMake(50, 0, 100,35)];
Label.backgroundColor=[UIColor clearColor];
Label.userInteractionEnabled=YES;
Label.text =[PicNameArrayobjectAtIndex:indexPath.row];
Label.textColor =[UIColor whiteColor];
Label.textAlignment =UITextAlignmentLeft;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell.contentView addSubview:Label];
//添加红箭头
UIImageView * ImageView =[[UIImageViewalloc]initWithFrame:CGRectMake(275, 5, 30, 30)];
ImageView.image = [ArrowArray objectAtIndex:indexPath.row];
[cell.contentView addSubview:ImageView];
}
else{
UIImageView * Image3View =[[UIImageViewalloc]initWithFrame:CGRectMake(10, 7, 25, 25)];
Image3View.image = [pic2Array objectAtIndex:indexPath.row];
[cell.contentView addSubview:Image3View];
UILabel * Label =[[UILabel alloc]initWithFrame:CGRectMake(50, 0, 100,35)];
Label.backgroundColor=[UIColor clearColor];
Label.userInteractionEnabled=YES;
Label.text =[PicName2Array objectAtIndex:indexPath.row];
Label.textColor =[UIColor whiteColor];
Label.textAlignment =UITextAlignmentLeft;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell.contentView addSubview:Label];
//添加红箭头
UIImageView * Image1View =[[UIImageView alloc]initWithFrame:CGRectMake(275,5, 30, 30)];
Image1View.image = [Arrow2Array objectAtIndex:indexPath.row];
[cell.contentView addSubview:Image1View];
}
cell.textLabel.textAlignment =UITextAlignmentLeft;
cell.backgroundColor =[[UIColor alloc]initWithRed:0.28235294green:0.28235294 blue:0.28235294 alpha:1];
cell.textLabel.textColor=[UIColor whiteColor];
// cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
return cell;
}
// cell高度
-(float)tableView:(UITableView *)tableViewheightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 40;
}
// 模块标题
-(NSString *)tableView:(UITableView*)tableView titleForHeaderInSection:(NSInteger)section
{ if (section==0) {
return @"我的乐播";
}
else{
return @"其他";
}
}
// 自定义标题样式
-(UIView *)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section
{
UIView * Viee =[[UIView alloc]init];
Viee.backgroundColor=[UIColor clearColor];
UILabel *Vieee =[[UILabel alloc]init];
Vieee.backgroundColor=[UIColor clearColor];
Vieee.textColor = [UIColor whiteColor];
if (section==0) {
Vieee.text=@" 我的乐播";
}
else{
Vieee.text=@" 其他";
}
return Vieee;
return Viee;
}
tableView 可视区域定义
[DiscussTableView scrollRectToVisible:CGRectMake(0,height-Frame.size.height, 320, Frame.size.height) animated:YES];
// 获取for循环中的 imageview的方法
UIImageView * ImageViewL =(UIImageView *)[ScreenView viewWithTag:400];
ImageViewL.hidden=YES;
//手写button添加事件方法
[ScreenBtn addTarget:self action:@selector(ScreenBtn:)forControlEvents:UIControlEventTouchUpInside];
//小按钮方法内容 ********类型
-(void)littleBtn:(id)sender
{
// 获取for循环中的Button方法
UIButton * Btn =(UIButton *)sender;
UIScrollView * ScrollView =(UIScrollView *)[ScreenView viewWithTag:300];
for (UIButton *button in ScrollView.subviews) {
if (button.tag >=100 && button.tag<106) {
[button setBackgroundImage:nil forState:UIControlStateNormal];
[button setTitleColor:[UIColor grayColor]forState:UIControlStateNormal];
}
}
[Btn setBackgroundImage:[UIImage imageNamed:@"3-点播-本地专区_12.png"] forState:UIControlStateNormal];
[Btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
//scrollview定义滑动距离
classScrollView.contentSize=CGSizeMake((classBtn.frame.size.width+20)*number,classScrollView.frame.size.height);
// 视频列表scroll 代理方法 ******开始滑动
-(void)scrollViewWillBeginDragging:(UIScrollView*)scrollView
// 视频列表scroll 代理方法 ****** 监测scrollview滑动坐标
-(void) scrollViewDidScroll:(UIScrollView*) scrollView{
// 根据滑动的x轴坐标判断
if(scrollView.contentOffset.x==0) {
// 去除ScrollView滚动条
classScrollView.showsHorizontalScrollIndicator = FALSE;
NSLOG格式
//显示导航栏
self.navigationController.navigationBar.hidden=NO;
//显示电池栏
[[UIApplication sharedApplication] setStatusBarHidden:NO];
NSArray *fontArray = [UIFontfamilyNames];
NSLog(@"%@",fontArray);