我有一个iPhone应用程序,我在其中创建了一个发射器和一个接收器.但是,当屏幕锁定或应用程序被发送到后台时,发射器停止发送.
我还能在后台继续传输(又称广告,广播)吗?
我是iOS新手.我创建了一个登录页面,一切正常.我使用JSON检查用户名和密码,并以字典格式从服务器获得响应.我想从字典中提取值并在我的程序中检查它们.我从服务器得到的响应是:
json: {
error = 0;
msg = "";
value = {
user = false;
};
};
Run Code Online (Sandbox Code Playgroud)
首先,我想检查带键的值error是否为0或1.然后我想用密钥检查值user.我不知道应该如何编码来检查它.有人可以帮忙吗?
我试过的代码如下:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *respString = [[NSString alloc] initWithData:loginJSONData encoding:NSUTF8StringEncoding];
SBJsonParser *objSBJSONParser = [[SBJsonParser alloc] init];
NSDictionary *json = [[NSDictionary alloc] initWithDictionary:[objSBJsonParser objectWithString:respString]];
NSLog(@"json: %@",json);
NSString *error = [json objectForKey:@"error"];
NSLog(@"error: %@", error);
if ([error isEqualToString:@"o"])
{
NSLog(@"login successful");
}
else
{
NSLog(@"login fail"); …Run Code Online (Sandbox Code Playgroud) 我在XCode 6.1中收到以下警告.
属性不可用:8.0之前的iOS版本的第一个基线布局属性
我想,这也导致我的iOS 7.x版本崩溃.
我使用的是UIAlertController提出了一个对话UITextField和一个UIAlertAction按钮标记为"好".如何将多个字符(例如5个字符)输入到UITextField?中,如何禁用该按钮?
当我打印日期时
//getting the current date and time
self.date = [NSDate date];
NSLog(@"%@",date);
Run Code Online (Sandbox Code Playgroud)
我得到的日期是正确的,但是时间延迟了6小时.我的系统时间是正确的.
我有一个NSString,我想检查它是否有NULL值.如果是,那么if条件应该执行.否则它应该执行else条件.
以下是我使用的代码:
if ([appDelegate.categoryName isEqual:[NSNull null]])
{
select = [[NSString alloc] initWithFormat:@"select * FROM ContentMaster LEFT JOIN Category ON ContentMaster.CategoryID=Category.CategoryID where ContentMaster.ContentTagText='%@'", appDelegate.tagInput];
}
else
{
select = [[NSString alloc] initWithFormat:@"select * FROM ContentMaster LEFT JOIN Category ON ContentMaster.CategoryID=Category.CategoryID LEFT JOIN Topic ON ContentMaster.TopicID=Topic.TopicID where ContentMaster.ContentTagText='%@' && Category.CategoryName='%@' && Topic.TopicName='%@'", appDelegate.tagInput, appDelegate.categoryName, appDelegate.topicName];
}
Run Code Online (Sandbox Code Playgroud)
它总是执行else条件,而不是if条件,即使值是NULL.
我想用这个POST方法调用一个Web服务.我需要发布一个带有URL的字典.我的Web服务参数如下:
ConversationMessage {
authorUserId (string, optional),
subject (string, optional),
hasAttachment (boolean, optional),
conversationId (string, optional),
attachment (DigitalAsset, optional),
content (string, optional),
title (string, optional),
urgency (boolean, optional),
searchable (Map[String,Object], optional)
}
DigitalAsset {
id (string, optional),
assetUrl (string, optional),
assetContent (string, optional),
thumbGenerated (boolean, optional),
fileName (string, optional)
}
Map[String,Object] {
empty (boolean, optional)
}
Run Code Online (Sandbox Code Playgroud)
以下是我的要求:
NSMutableArray *arr=[[NSMutableArray alloc]init];
NSMutableDictionary *dict=[[NSMutableDictionary alloc]init];
[dict setValue:@"test title" forKey:@"title"];
[dict setValue:@"test message" forKey:@"content"];
[dict setValue:@"0" forKey:@"urgency"];
[arr addObject:[NSMutableDictionary dictionaryWithObject:dict forKey:@"ConversationMessage"]];
NSMutableURLRequest …Run Code Online (Sandbox Code Playgroud) 以下是初始化我的代码UISegmentedControl.
- (void)initializeToolButtons
{
NSArray *buttonTitles = [NSArray arrayWithObjects:@"ANNEXET", @"HOVET", @"GLOBEN", "ALL", nil];
toolbuttons = [[UISegmentedControl alloc] initWithItems:buttonTitles];
toolbuttons.segmentedControlStyle = UISegmentedControlStyleBar;
toolbuttons.tintColor = [UIColor darkGrayColor];
toolbuttons.backgroundColor = [UIColor blackColor];
toolbuttons.frame = CGRectMake(0, 0, 320, 30);
[toolbuttons addTarget:self action:@selector(toolButtonsAction) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:toolbuttons];
}
Run Code Online (Sandbox Code Playgroud)
如何减少每个项目的字体大小UISegmentedControl?
注意: toolButtons已经在全球范围内声明.
我需要详细解释以下内容:
我们用什么用UIViewController?有什么用?
我有一个类似于以下的类:
class one
{
UINavigationController *nav = ...;
two *secondObject = ...;
// By use of it, I have push the new view class two//ok
}
class two
{
...
}
Run Code Online (Sandbox Code Playgroud)
我怎么secondObject在课堂上使用one?
从窗口开始的类层次结构是什么?
我正在开发一个应用程序,其中UIViewController(firstViewController)包含some UILabels,a UIButton和a UIView(subView).在UIView应该显示UIViewController(secondViewController),其中包含一些层.我无法做到这一点.
我应该怎么做,以显示secondViewController内子视图的 firstViewController?
我对某些东西感到困惑.我正在尝试创建一个自定义单元格,我想使用界面生成器方式.
我创建表的正常方法是将表作为:
.H
@interface AssessList : UIViewController {
IBOutlet UITableView *tblAssessList;
}
@property(nonatomic, retain) UITableView *tblAssessList;
@end
Run Code Online (Sandbox Code Playgroud)
.M
- (NSInteger)
numberOfSectionsInTableView:(UITableView *)tableView {
return groupArray.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return totalArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = @"I am the text....";
return cell;
}
Run Code Online (Sandbox Code Playgroud)
现在我已经为单元格创建了一个新类,我想我知道如何将它放入.但是我可以将.h保留为
@interface AssessList : UIViewController
Run Code Online (Sandbox Code Playgroud)
或者带有完整表的类/ nib是否 …
ios ×11
objective-c ×4
iphone ×2
json ×2
uiview ×2
xcode ×2
autolayout ×1
class ×1
composition ×1
fonts ×1
ibeacon ×1
ios7 ×1
ios8 ×1
nsdate ×1
nsdictionary ×1
nsstring ×1
null ×1
size ×1
subview ×1
uitableview ×1
uitextfield ×1