- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章iOS开发之路--微博“更多”页面由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
最终效果图
。
moreviewcontroller.m 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
//
// moreviewcontroller.m
// 20_帅哥no微博
//
// created by beyond on 14-8-4.
// copyright (c) 2014年 com.beyond. all rights reserved.
//
#import "moreviewcontroller.h"
@interface moreviewcontroller ()
{
// more.plist根是字典,有两对key value,其中有一对是zh_cn,对应的值是数组,数组的长度就是有多少个分组,数组的每一个元素也是一个数组,
// 由不同的分组,组成的数组
nsarray *_groups;
}
@end
@implementation moreviewcontroller
- (
void
)viewdidload
{
[super viewdidload];
log
(@
"view %@"
,nsstringfromcgrect(self.view.frame)) ;
// 1.设置导航条上面 右边的设置按钮
[self setrightbarbuttonitem];
// 2.加载more.plist
[self loadplistofmore];
// 3.设置tableview的全局背景
[self settableviewglobalbg];
// 4.添加 退出按钮 到tableview的最底部的tablefooterview
[self addeixtbtnatbottom];
}
// 1,设置导航条上面 右边的按钮
- (
void
)setrightbarbuttonitem
{
self.navigationitem.rightbarbuttonitem = [[uibarbuttonitem alloc] initwithtitle:@
"设置"
style:uibarbuttonitemstyleplain target:self action:@selector(settings)];
}
// 2,加载more.plist文件
- (
void
)loadplistofmore
{
nsurl *url = [[nsbundle mainbundle] urlforresource:@
"more"
withextension:@
"plist"
];
// 由一个个分组 组成的数组,分组的成员也就是数组,则一行行组成的数组
_groups = [nsdictionary dictionarywithcontentsofurl:url][@
"zh_cn"
];
}
// 3,设置tableview的全局背景
- (
void
)settableviewglobalbg
{
// 清除ios 7 中tableview顶部的多出的空白区域
self.automaticallyadjustsscrollviewinsets = no;
// 设置scrollview额外的滚动区域
// self.tableview.contentinset = uiedgeinsetsmake(<#cgfloat top#>, <#cgfloat left#>, <#cgfloat bottom#>, <#cgfloat right#>)
// 重要~ ~当tableview的样式为group时,如果想更换背景,必须先清除条纹状的自带的backgroundview,然后才可以设置tableview的背景颜色
self.tableview.backgroundview = nil;
self.tableview.backgroundcolor = kglobalbg;
// 缩小每一分组之间的间距
self.tableview.sectionheaderheight = 0;
self.tableview.sectionfooterheight = 5;
}
// 4,创建退出按钮 并添加到tableview的最底部的tablefooterview
- (
void
)addeixtbtnatbottom
{
// 1,创建一个footerview,将它作为tableview的tablefooterview
uiview *footerview = [[uiview alloc] init];
// tableview的tablefooterview的宽度固定是320,只有高度可调节
footerview.frame = cgrectmake(0, 0, 320, 60);
// 将刚才创建的footerview作为tableview的tablefooterview,目的是防止用户点击底部dockitem时不小心点到了退出按钮,因此要设置一个额外的空间,补充一下tablefooterview的宽度固定是320
self.tableview.tablefooterview = footerview;
// 2,创建退出按钮 并添加到tableview的最底部的tablefooterview
uibutton *btnexit = [uibutton buttonwithtype:uibuttontypecustom];
// footerview是作为tableview的tablefooterview存在,按钮是加到了footerview里面,这儿按钮的frame x 10 y 5是相对于footerview的
btnexit.frame = cgrectmake(10, 5, 300, 40);
// 按钮上字体大小
btnexit.titlelabel.font = [uifont systemfontofsize:17];
// 按钮的监听点击事件
[btnexit addtarget:self action:@selector(exitbtnclick) forcontrolevents:uicontroleventtouchupinside];
// 分类方法,设置按钮正常和高亮时背景图片(可拉伸)
[btnexit setbtnbgimgfornormalandhighightedwithname:@
"common_button_red.png"
];
// 设置按钮上的文字,最后一组,数组只有一行,每一行就是一个字典
nsstring *btntitle = [_groups lastobject][0][@
"name"
];
[btnexit settitle:btntitle forstate:uicontrolstatenormal];
// 3,最重要的一步,将刚才创建的 退出按钮 添加到tableview的tablefooterview
//[footerview addsubview:btnexit];
[self.tableview.tablefooterview addsubview:btnexit];
}
// 响应点击设置点击事件
- (
void
)settings
{
log
(@
"点击了设置按钮"
);
}
// 点击 退出按钮
- (
void
)exitbtnclick
{
// cancelbuttontitle 黑色
// destructivebuttontitle 红色
// otherbuttontitles 灰白色
uiactionsheet *actionsheet = [[uiactionsheet alloc] initwithtitle:@
"确定退出此账号?"
delegate:nil cancelbuttontitle:@
"取消"
destructivebuttontitle:@
"红色"
otherbuttontitles:@
"其他"
, nil];
// uiactionsheet最好是显示到window上面,这样就不怕点不中了,因为有时候控制器的view不一定占整个窗口大小
[actionsheet showinview:self.view.window];
}
// 点击 设置按钮
- (
void
)setting
{
log
(@
"设置"
);
}
// 代理方法,点击了某行时调用
- (
void
)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath
{
[tableview deselectrowatindexpath:indexpath animated:yes];
}
#pragma mark - 数据源方法
// 共有多少组 最后一个组是特别的退出按钮,故不进入循环使用
- (nsinteger)numberofsectionsintableview:(uitableview *)tableview
{
return
_groups.count - 1;
}
// 每一组的行数
- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section
{
// 取得由每一行组成的数组
nsarray *rows = _groups[section];
// 返回该组的行数
return
rows.count;
}
// 每一组的每一行显示特有的内容
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath
{
static
nsstring *cellid = @
"beyond"
;
// 1.先获得池中的cell
uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellid];
// 如果为空,才创建新的
if
(cell == nil) {
// 创建新的cell
cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellid];
// 1.1.清除文本标签的背景
cell.textlabel.backgroundcolor = [uicolor clearcolor];
// 1.2.设置文本标签高亮时的文字颜色同样为默认的文字颜色 (不让它变色)
cell.textlabel.highlightedtextcolor = cell.textlabel.textcolor;
// 1.3.重点,创建时就,初始化cell的背景view和选中时的背景view
uiimageview *bgimgview = [[uiimageview alloc] init];
cell.backgroundview = bgimgview;
uiimageview *selectedbgimgview = [[uiimageview alloc] init];
cell.selectedbackgroundview = selectedbgimgview;
}
// 2.设置cell独一无二的内容
// 设置显示的标题文字 第几组-->第几行--->字典
cell.textlabel.text = _groups[indexpath.section][indexpath.row][@
"name"
];
// 3.设置cell的背景图片
// 先取出cell背景view
uiimageview *bgimgview = (uiimageview *)cell.backgroundview;
uiimageview *selectedbgimgview = (uiimageview *)cell.selectedbackgroundview;
// 分情况得出cell的背景图片文件名
// 该组中,由每一行组成的数组
nsarray *rows = _groups[indexpath.section];
// 得到该组的,总行数
int
rownum = rows.count;
nsstring *name = nil;
if
(rownum == 1) {
// 如果所在组只有一行,使用四角全是半角的图片
name = @
"common_card_background.png"
;
}
else
if
(indexpath.row == 0) {
// 如果所在组不只一行,且当前行是所在组的第一行,使用上半为圆角的图片
name = @
"common_card_top_background.png"
;
}
else
if
(indexpath.row == rownum - 1) {
// 如果所在组不只一行,且当前行是所在组的最后一行,使用下半为圆角的图片
name = @
"common_card_bottom_background.png"
;
}
else
{
// 中间
// 如果所在组不只一行,且当前行不在组的第一行也不在组的最后一行,使用四周无圆角的图片
name = @
"common_card_middle_background.png"
;
}
// 设置cell的正常和选中时的背景图片
bgimgview.image = [uiimage imagestretchedwithname:name];
selectedbgimgview.image = [uiimage imagestretchedwithname:[name filenameinsertsuffixbeforeextension:@
"_highlighted"
]];
// 4.设置最右边的箭头指示器,分文字和图片两种情况讨论
if
(indexpath.section == 2) {
// 如果是第2组 ,则显示文字,"阅读模式 - 主题"
uilabel *label = [[uilabel alloc] init];
// 清除标签背景色
label.backgroundcolor = [uicolor clearcolor];
// 标签文字大小
label.font = [uifont systemfontofsize:13];
// 标签文字颜色
label.textcolor = [uicolor graycolor];
// 标签文字靠右
label.textalignment = nstextalignmentright;
// 标签frame的宽高
label.bounds = cgrectmake(0, 0, 100, 30);
// 该组的第1行显示 "有图模式" ,第2行显示 "经典主题"
label.text = (indexpath.row == 0) ? @
"有图模式"
: @
"经典主题"
;
// 最后将自定义最右边的view设置为cell的附属view
cell.accessoryview = label;
}
else
{
// 如果是其他的组,显示向右的图片箭头
cell.accessoryview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@
"common_icon_arrow.png"
]];
}
// 5.返回cell
return
cell;
}
@end
|
『更多』页面的数据来源more.plist 。
最后此篇关于iOS开发之路--微博“更多”页面的文章就讲到这里了,如果你想了解更多关于iOS开发之路--微博“更多”页面的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
IO 设备如何知道属于它的内存中的值在memory mapped IO 中发生了变化? ? 例如,假设内存地址 0 专用于保存 VGA 设备的背景颜色。当我们更改 memory[0] 中的值时,VGA
我目前正在开发一个使用Facebook sdk登录(通过FBLoginView)的iOS应用。 一切正常,除了那些拥有较旧版本的facebook的人。 当他们按下“使用Facebook登录”按钮时,他
假设我有: this - is an - example - with some - dashesNSRange将使用`rangeOfString:@“-”拾取“-”的第一个实例,但是如果我只想要最后
Card.io SDK提供以下详细信息: 卡号,有效期,月份,年份,CVV和邮政编码。 如何从此SDK获取国家名称。 - (void)userDidProvideCreditCardInfo:(Car
iOS 应用程序如何从网络服务下载图片并在安装过程中将它们安装到用户的 iOS 设备上?可能吗? 最佳答案 您无法控制应用在用户设备上的安装,因此无法在安装过程中下载其他数据。 只需在安装后首次启动应
我曾经开发过一款企业版 iOS 产品,我们公司曾将其出售给大型企业,供他们的员工使用。 该应用程序通过 AppStore 提供,企业用户获得了公司特定的配置文件(包含应用程序配置文件)以启用他们有权使
我正在尝试将 Card.io SDK 集成到我的 iOS 应用程序中。我想为 CardIO ui 做一个简单的本地化,如更改取消按钮标题或“在此保留信用卡”提示文本。 我在 github 上找到了这个
我正在使用 CardIOView 和 CardIOViewDelegate 类,没有可以设置为 YES 的 BOOL 来扫描 collectCardholderName。我可以看到它在 CardIOP
我有一个集成了通话工具包的 voip 应用程序。每次我从我的 voip 应用程序调用时,都会在 native 电话应用程序中创建一个新的最近通话记录。我在 voip 应用程序中也有自定义联系人(电话应
iOS 应用程序如何知道应用程序打开时屏幕上是否已经有键盘?应用程序运行后,它可以接收键盘显示/隐藏通知。但是,如果应用程序在分屏模式下作为辅助应用程序打开,而主应用程序已经显示键盘,则辅助应用程序不
我在模拟器中收到以下错误: ImageIO: CGImageReadSessionGetCachedImageBlockData *** CGImageReadSessionGetCachedIm
如 Apple 文档所示,可以通过 EAAccessory Framework 与经过认证的配件(由 Apple 认证)进行通信。但是我有点困惑,因为一些帖子告诉我它也可以通过 CoreBluetoo
尽管现在的调试器已经很不错了,但有时找出应用程序中正在发生的事情的最好方法仍然是古老的 NSLog。当您连接到计算机时,这样做很容易; Xcode 会帮助弹出日志查看器面板,然后就可以了。当您不在办公
在我的 iOS 应用程序中,我定义了一些兴趣点。其中一些有一个 Kontakt.io 信标的名称,它绑定(bind)到一个特定的 PoI(我的意思是通常贴在信标标签上的名称)。现在我想在附近发现信标,
我正在为警报提示创建一个 trigger.io 插件。尝试从警报提示返回数据。这是我的代码: // Prompt + (void)show_prompt:(ForgeTask*)task{
您好,我是 Apple iOS 的新手。我阅读并搜索了很多关于推送通知的文章,但我没有发现任何关于 APNS 从 io4 到 ios 6 的新更新的信息。任何人都可以向我提供 APNS 如何在 ios
UITabBar 的高度似乎在 iOS 7 和 8/9/10/11 之间发生了变化。我发布这个问题是为了让其他人轻松找到答案。 那么:在 iPhone 和 iPad 上的 iOS 8/9/10/11
我想我可以针对不同的 iOS 版本使用不同的 Storyboard。 由于 UI 的差异,我将创建下一个 Storyboard: Main_iPhone.storyboard Main_iPad.st
我正在写一些东西,我将使用设备的 iTunes 库中的一部分音轨来覆盖 2 个视频的组合,例如: AVMutableComposition* mixComposition = [[AVMutableC
我创建了一个简单的 iOS 程序,可以顺利编译并在 iPad 模拟器上运行良好。当我告诉 XCode 4 使用我连接的 iPad 设备时,无法编译相同的程序。问题似乎是当我尝试使用附加的 iPad 时
我是一名优秀的程序员,十分优秀!