我正在使用导航应用程序.我将First ViewController推送到Second ViewController,从Second ViewController推送到Third ViewController.现在我想从Third ViewController弹出到First ViewController.我正在使用下面的代码执行此任务,但我的应用程序崩溃了.
请任何机构给我一些适当的指导.我不能使用pop到rootViewController,因为它是不同的viewController.提前致谢...
在第三个ViewControler中我写了这个:
FirstViewCtr *x=[[FirstViewCtr alloc] initWithNibName:@"FirstViewCtr" bundle:nil];
[self.navigationController popToViewController:x animated:NO];
Run Code Online (Sandbox Code Playgroud) 在xcode 7.2中,对象列表中没有Storyboard Entry Point项.我需要使用Storyboard Entry Point,我在谷歌搜索中找不到任何类似的问题所以任何人都可以帮助我.
嗨,我是iOS的新手,我正在尝试使用JSON从Web服务获得响应,但发生以下错误.请帮我解决一下.
Error Domain = NSCocoaErrorDomain Code = 3840"操作无法完成.(Cocoa error 3840.)"(JSON文本没有以数组或对象开头,并且选项允许未设置片段.)UserInfo = 0x7fd30bee0f70 {NSDebugDescription = JSON text没有从数组或对象和选项开始,以允许未设置片段.,NSUnderlyingError = 0x7fd30bede7b0"请求失败:内部服务器错误(500)"}
-(void)loadFeedWithOffset:(NSInteger)Offset Limit:(NSInteger)Limit
{
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
// [manager.requestSerializer setValue:@"application/json; text/html" forHTTPHeaderField:@"Accept"];
// [manager.requestSerializer setValue:@"application/json; text/html; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setValue:[[NSUserDefaults standardUserDefaults] objectForKey:@"UID"] forKey:@"user_id"];
[params setValue:[NSString stringWithFormat:@"%ld",(long)Offset] forKey:@"offset"];
[params setValue:[NSString stringWithFormat:@"%ld",(long)Limit] forKey:@"limit"];
[params setValue:[NSString stringWithFormat:@"%d",[AppDelegate sharedAppDelegate].intPostType] forKey:@"post_type"];
[manager POST:[NSString stringWithFormat:@"%@webservices/post/load", API_URL] parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject)
{
NSLog(@"JSON: %@", responseObject);
if ([[responseObject objectForKey:@"status"] …Run Code Online (Sandbox Code Playgroud) Run Code Online (Sandbox Code Playgroud)Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object'
.h
@property (nonatomic, strong) NSMutableArray *history;
Run Code Online (Sandbox Code Playgroud)
.m
- (void)tableView:(UITableView *)tableView commitEditingStyle: (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
NSString *de = [[self.history objectAtIndex:indexPath.row] objectForKey:@"des"];
NSString *dest = [de stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *jsonURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://example.com/rm_history.php?user_id=%@&destinations=%@",self.uID,dest]];
NSData *jsonData = [NSData dataWithContentsOfURL:jsonURL];
[self.history removeObjectAtIndex:indexPath.row];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil]
withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
NSLog(@"create");
// Create a new instance …Run Code Online (Sandbox Code Playgroud) 我正在使用 SDWebImage库来处理图像缓存。我实现了一种从服务器下载图像并在tableView. 这是我下载图像并在tableViewCell
In中显示的代码cellForRowAtIndexPath,我执行了以下代码
[cell.profileImageView sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:nil options:SDWebImageRefreshCached];
Run Code Online (Sandbox Code Playgroud)
它在这里完美地工作。但是当我更新服务器上的图像时,tableViewCell仍然显示相同的图像。问题是,它的缓存没有更新图像。我用相同的关键字进行搜索,并在 StackOverflow 上发现了这个问题。但无法解决问题。我还尝试清除内存和缓存viewDidDisappear
-(void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:YES];
[[SDImageCache sharedImageCache]clearMemory];
[[SDImageCache sharedImageCache]clearDisk];
}
Run Code Online (Sandbox Code Playgroud)
但这不是有效的方法。当服务器上的图像更新时,是否有其他方法来更新缓存?
我有这个枚举:
enum DealStatus:String {
case PENDING = "Pending"
case ACTIVE = "Active"
case STOP = "Stop"
case DECLINED = "Declined"
case PAUSED = "Paused"
}
Run Code Online (Sandbox Code Playgroud)
和结构:
struct ActiveDeals: Decodable {
let keyword: String
let bookingType: String
let expiryDate: Int
let createdAt: Int?
let shopLocation: String?
let dealImages: [DealImages]?
let dealStatus: String?
let startingDate: Int?
}
Run Code Online (Sandbox Code Playgroud)
在结构中我试图将枚举作为类型分配dealStatus如下:
struct ActiveDeals: Decodable {
let keyword: String
let bookingType: String
let expiryDate: Int
let createdAt: Int?
let shopLocation: String?
let dealImages: [DealImages]? …Run Code Online (Sandbox Code Playgroud) 因为我更新到angular7,我收到错误?
"dependencies": {
"@angular/animations": "^7.0.3",
"@angular/common": "^7.0.3",
"@angular/compiler": "^7.0.3",
"@angular/core": "^7.0.3",
"@angular/forms": "^7.0.3",
"@angular/http": "^7.0.3",
"@angular/platform-browser": "^7.0.3",
"@angular/platform-browser-dynamic": "^7.0.3",
"@angular/platform-server": "^7.0.3",
"@angular/router": "^7.0.3",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.9",
"@types/lodash": "^4.14.116",
"bootstrap": "^4.1.3",
"core-js": "^2.5.7",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"ng-connection-service": "^1.0.4",
"ngx-perfect-scrollbar": "^6.3.1",
"ngx-toastr": "^9.1.0",
"ngx-ui-switch": "^1.6.0",
"rxjs": "^6.3.3",
"rxjs-compat": "^6.3.3",
"web-animations-js": "2.3.1",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.10.5",
"@angular/cdk": "^6.4.7",
"@angular/cli": "^7.0.5",
"@angular/compiler-cli": "^7.0.3",
"@angular/language-service": "^7.0.3",
"@angular/material": "^6.4.7",
"@types/jasmine": "^2.8.11",
"@types/jasminewd2": "~2.0.2",
"@types/node": "^10.12.6",
"codelyzer": "^4.5.0",
"jasmine-core": "^3.3.0",
"jasmine-spec-reporter": "^4.2.1",
"karma": …Run Code Online (Sandbox Code Playgroud) datetimepicker bootstrap-datetimepicker ng-bootstrap angular7
我有一个UILabel子视图,UIButton我从另一个视图传递值并填充UILabel.现在,我希望UILabel
必须根据内容更改其高度.如果文本为"Hello",则必须为1行,但如果文本为"我的文本太长而无法放入标签",则必须更改其大小.我用过
[self.addressLabel sizeToFit];
Run Code Online (Sandbox Code Playgroud)
但为此,我需要在UILabel下留下空白空间.我想要的是,当文本强度增加时,UILabel和UIView的大小必须扩展.
在我的react-native项目中,我有“boost-for-react-native”的依赖并像这样安装它:
pod 'boost-for-react-native', :podspec => 'https://raw.githubusercontent.com/react-native-community/boost-for-react-native/master/boost-for-react-native.podspec'
Run Code Online (Sandbox Code Playgroud)
最近工作得很好。我不确定发生了什么变化,但我现在无法安装 Pod。当我运行 pod install 时出现此错误
[!] CocoaPods could not find compatible versions for pod "boost-for-react-native":
In Podfile:
Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`) was resolved to 2018.10.22.00, which depends on
boost-for-react-native
React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) was resolved to 0.61.5, which depends on
boost-for-react-native (= 1.63.0)
boost-for-react-native (from `https://raw.githubusercontent.com/react-native-community/boost-for-react-native/master/boost-for-react-native.podspec`)
Run Code Online (Sandbox Code Playgroud)
我尝试过删除node_modules、删除podfile.lock、分解pod。我还尝试将 podfile 和应用程序目标中的部署版本升级到 11.0。但我仍然收到上述错误。
我将非常感谢对此的任何帮助。谢谢
UITextField *textField;
NSInteger intRollNumber;
Run Code Online (Sandbox Code Playgroud)
我想从中获取rollNumber输入textField并将值存储到intRollNumber.
我是怎么做到的?因为我无法将字符串转换为整数.
我有UITableView1个部分和numberOfRows:来自NSMutableArray.
我想要的是每当UITableView出现滚动视图时必须滚动到最后一行.
为此我想要indexPath最后一行.怎么弄?
我知道这个问题已被多次回答.但这些方法都不适合我.
这是我试过的代码
-(NSIndexPath*)lastIndexPath{
NSInteger sectionsAmount = [myTableView numberOfSections];
NSInteger rowsAmount = [myTableView numberOfRowsInSection:sectionsAmount-1];
NSIndexPath *lastIndexPath = [NSIndexPath indexPathForRow:(rowsAmount - 1) inSection:(sectionsAmount - 1)];
return lastIndexPath;
}
Run Code Online (Sandbox Code Playgroud) objective-c ×6
ios ×5
iphone ×2
swift ×2
uitableview ×2
angular7 ×1
cocoapods ×1
decodable ×1
enums ×1
ios7.1 ×1
json ×1
ng-bootstrap ×1
nsinteger ×1
react-native ×1
sdwebimage ×1
struct ×1
uilabel ×1
uistoryboard ×1
uitextfield ×1
web-services ×1
xcode5.1 ×1
xcode7.2 ×1