我一直收到以下错误:
Storyboard (<UIStoryboard: 0x7ebdd20>) doesn't contain a view controller
with identifier 'drivingDetails'
Run Code Online (Sandbox Code Playgroud)
这是代码:
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"drivingDetails"];
controller.title = [[dao libraryItemAtIndex:indexPath.row] valueForKey:@"name"];
[self.navigationController pushViewController:controller animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
我已经设置了identifier,UIStoryboard但我仍然收到此错误.

搜索我发现可能的方法是使用UICollectionView,所以没有问题,因为有很多关于Stack Overflow的教程和问题.我有3个问题:
我找不到任何关于"分隔符"(划分所有框的行).我喜欢它不会水平触摸屏幕边框.它是以编程方式完成的吗?
为了在所有设备中平均分配空间(水平3个盒子/按钮),我找到了这个答案答案.这是正确的方法吗?
对于模糊效果,我找到了这个答案: 如何在UITableView中使用自适应segue实现UIVisualEffectView
对于TableView它将是:
if (!UIAccessibilityIsReduceTransparencyEnabled()) {
tableView.backgroundColor = UIColor.clearColor()
let blurEffect = UIBlurEffect(style: .Light)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
tableView.backgroundView = blurEffectView
}
Run Code Online (Sandbox Code Playgroud)
我可以这样做吗?
@IBOutlet var collectionView: UICollectionView!
if (!UIAccessibilityIsReduceTransparencyEnabled()) {
collectionView.backgroundColor = UIColor.clearColor()
let blurEffect = UIBlurEffect(style: .Light)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
collectionView.backgroundView = blurEffectView
}
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我有这个类从我的服务器获取数据:
class Api{
func loadOffers(completion:(([Offers])-> Void), offer_id: String, offerStatus:String){
let myUrl = NSURL(string: "http://www.myServer.php/api/v1.0/offers.php")
let request = NSMutableURLRequest(URL: myUrl!)
request.HTTPMethod = "POST"
let postString = "offer_id=\(offer_id)&offerStatus=\(dealStatus)&action=show"
request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)
let task = NSURLSession.sharedSession().dataTaskWithRequest(request)
{ data, response, error in
if error != nil {
println("error\(error)")
}else{
var err:NSError?
let jsonObject : AnyObject! = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil)
if let dict = jsonObject as? [String: AnyObject] {
if let myOffers = dict["offers"] as? [AnyObject] {
var offers = [Offers]() …Run Code Online (Sandbox Code Playgroud) 我有一个像这样的plist:
<dict>
<key>New item</key>
<dict>
<key>document</key>
<string>driving licence</string>
<key>Overview</key>
<string>a driving licence is required.......</string>
</dict>
Run Code Online (Sandbox Code Playgroud)
如果我想获得对象,我会写这样的东西:
myString = [somedictionary objectForKey:@"Overview"];
Run Code Online (Sandbox Code Playgroud)
如果我想从我的plist得到"概述"怎么样?我希望它很清楚.....请不要投反对票....我还在学习!;-)
编辑版:
更具体地说:
我有这个代码
for (NSDictionary *playDictionary in playDictionariesArray) {
Play *play = [[Play alloc] init];
play.name = [playDictionary objectForKey:@"playName"];
Run Code Online (Sandbox Code Playgroud)
这是Apple示例代码:http: //developer.apple.com/library/ios/#samplecode/TableViewUpdates/Introduction/Intro.html
在此示例中,字符串播放在标题部分返回播放的名称,但我想修改它并在标题中获取"Key"(在这种情况下将是"PlayName").
感谢每一个人:这就是我如何修复它:
NSMutableArray *anArray = [[NSMutableArray alloc] init];
[anArray addObject:@"Overview"];
[anArray addObject:@"pre-requirements"];
[anArray addObject:@"where"];
[anArray addObject:@"what"];
//Use a for each loop to iterate through the array
for (NSString *s in anArray) {
Play *play = [[Play …Run Code Online (Sandbox Code Playgroud) 我在这里和这里找到了一些信息, 但我没有找到关于此事的教程或好书.
我不想使用Parse有很多原因所以我决定尝试自己编写Web服务代码.(我希望这是命名它的正确方法).
我买了不同的书,虽然它很好地解释了我应该如何使用JSON或XML从数据库中检索数据,但我找不到有关数据插入的任何明确内容.
这就是我最终设法将我的数据从iphone应用程序插入到我的数据库的方式.
XCODE:
-(IBAction)addData:(id)sender{
[self displayActivityIndicator];
NSString *country = self.countryLabel.text;
NSString *location = self.locationTextField.text;
NSString *city = self.cityTextField.text;
NSString *distance = self.distanceTextField.text;
NSString *max_part = self.partcipantsTextField.text;
NSString *pace = self.paceField.text;
NSString *rawStr = [NSString stringWithFormat:@"country=%@&location=%@&&city=%@&distance=%@&pace=%@&partecipant=%@", country,
location,
city,
distance,
pace,max_part];
NSData *data = [rawStr dataUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:@"http://www.mywebsite.com/savedata.php"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:data];
NSURLResponse *response;
NSError *err;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
NSString …Run Code Online (Sandbox Code Playgroud) 我是PHP和MySQL的新手,但我正在我的网站上实现Facebook PHP SDK.到目前为止一切正常,但我很难将用户数据添加到我的数据库(MySQL).我拥有的只是一个数字而不是用户名和oauth_uid(我得到两个字段的数字5).这是代码:
<?php
define('db_user','myUserName');
define('db_password','myPassword');
define('db_host','myHost');
define('db_name','myDbName');
// Connect to MySQL
$dbc = @mysql_connect (db_host, db_user, db_password) OR die ('Could not connect to MySQL: ' . mysql_error() );
// Select the correct database
mysql_select_db (db_name) OR die ('Could not select the database: ' . mysql_error() );
require 'lib/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => 'MYAPPID',
'secret' => 'MYSECRET',
'cookie' => true));
// Get User ID
$user = …Run Code Online (Sandbox Code Playgroud) 早上好,我终于设法在Facebook登录后将Facebook用户名存储在我的数据库中.唯一的问题是需要重新加载Facebook登录后用户被重定向到的页面(我第一次只得到一个空页面).你可以参考我之前的问题,因为我已经在那里发布了所有代码
更新:我注意到页面只需要第一次刷新(当用户信息尚未存储在数据库中时,它会快速且很好地加载页面.请帮助!;-)
UPDATE2:有没有办法在添加新用户后自动刷新页面(只需一次)?非常感谢!
更新3:我发布代码....它只有在我刷新页面时才有用....任何想法?
<?php
mysql_connect('host', 'username', 'password');
mysql_select_db('table');
require 'library/facebook.php';
// Create our Application instance
$facebook = new Facebook(array(
'appId' => 'MYID',
'secret' => 'MYSECRET',
'cookie' => true));
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}else{
header('location: index.php');
}
$query = mysql_query("SELECT * FROM users WHERE oauth_provider = …Run Code Online (Sandbox Code Playgroud) 当用户像Careem应用一样对地图进行拼写时,我想将MKAnnotaion保持在屏幕中央:
到目前为止,我设法显示了图钉,更新了图钉的位置,但是当我滚动地图时,代码中的注释最初移动了,然后又回到中心。我希望别针保持在中心。
@IBOutlet var mapView: MKMapView!
var centerAnnotation = MKPointAnnotation()
var manager:CLLocationManager!
override func viewDidLoad() {
super.viewDidLoad()
manager = CLLocationManager() //instantiate
manager.delegate = self // set the delegate
manager.desiredAccuracy = kCLLocationAccuracyBest // required accurancy
manager.requestWhenInUseAuthorization() // request authorization
manager.startUpdatingLocation() //update location
var lat = manager.location.coordinate.latitude // get lat
var long = manager.location.coordinate.longitude // get long
var coordinate = CLLocationCoordinate2DMake(lat, long)// set coordinate
var latDelta:CLLocationDegrees = 0.01 // set delta
var longDelta:CLLocationDegrees = 0.01 // set long
var span:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, …Run Code Online (Sandbox Code Playgroud) 我在splitViewController中有这2个tableViews(所有可用服务和提供的服务)。想法是,然后将单元格移动到屏幕中心,然后移动到服务提供的表视图。除了触摸`.be开始,其他所有东西都起作用,该单元格被添加到覆盖navBar的tableView的顶部。

我希望将视图/单元格添加到触摸开始的地方,在我正在触摸的“ ServiceCell”之上。我尝试将其添加到中,splitViewController.view但我认为我的逻辑有问题。
这里的代码:
func didLongPressCell (gr: UILongPressGestureRecognizer) {
let serviceCell:ServiceCell = gr.view as! ServiceCell
switch gr.state {
case .began:
let touchOffsetInCell = gr.location(in: gr.view)
let dragEvent = DragganbleServiceCell()
mDraggableServiceCell = dragEvent.makeWithServiceCell(serviceCell: serviceCell, offset: self.tableView.contentOffset, touchOffset: touchOffsetInCell)
self.splitViewController?.view.addSubview(mDraggableServiceCell!)
case .changed:
let cp:CGPoint = gr.location(in: self.view)
let newOrigin = CGPoint(x: (cp.x), y: (cp.y) - (mDraggableServiceCell?.touchOffset?.y)!)
UIView.animate(withDuration: 0.1, animations: {
self.mDraggableServiceCell?.frame = CGRect(origin: newOrigin, size: (self.mDraggableServiceCell?.frame.size)!)
})
case .ended:
let detailViewNC = self.splitViewController?.viewControllers[1] as! UINavigationController
let detailView …Run Code Online (Sandbox Code Playgroud) 我有这个警报视图(免责声明),当应用程序完成启动时弹出.它工作(我的应用程序现在慢得多),但如果用户按下,我也想退出应用程序no, thanks.我想我应该使用clickedButtonAtIndex:.
有人可以帮我吗?
2. viewDidLoad是应用程序启动时触发alertView的最佳方法吗?
3.有什么理由为什么现在我的应用程序在构建和运行时需要更多时间才能开始?
-(void)viewDidLoad {
UIAlertView *disclaimer = [[UIAlertView alloc] initWithTitle: @"DISCLAIMER" message:@"This Application is provided without any express or implied warranty. Errors or omissions in either the software or the data are not guaranteed against. The application is not intented to replace official documentation or operational procedure. In no event shal the developer be held liable for any direct or indirect damages arising from the use of this application" delegate:self cancelButtonTitle:@"No, thanks" otherButtonTitles:@"Accept", nil]; …Run Code Online (Sandbox Code Playgroud) ios ×7
swift ×4
iphone ×3
mysql ×3
objective-c ×3
php ×3
facebook ×2
api ×1
gridview ×1
ios4 ×1
json ×1
mkannotation ×1
mkmapview ×1
nsdictionary ×1
pdo ×1
storyboard ×1
uialertview ×1
xcode ×1