我正在开发我的第一个iPad快速应用程序.到目前为止,我有一个基本的mapview,底部工具栏中有一个按钮,我想刷新一次,并在点击后聚焦到用户位置.
目前我有这个代码:
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
var location: CLLocation!
let locationManager = CLLocationManager()
@IBOutlet weak var mapView: MKMapView!
@IBOutlet weak var refresh: UIBarButtonItem!
@IBAction func refresh(sender: AnyObject) {
let center = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))
self.mapView.setRegion(region, animated: true)
}
override func viewDidLoad() {
super.viewDidLoad()
self.locationManager.delegate = self
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.requestWhenInUseAuthorization()
self.locationManager.startUpdatingLocation()
self.mapView.showsUserLocation = true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// …Run Code Online (Sandbox Code Playgroud) 我有一个显示可选表情符号的集合视图。目前可以向我显示表情符号,这很好,但是有明显的灰色背景,这在图像文件本身中并不明显。
是否可以使这些表情符号图像的背景透明而不是灰色?
这是我的代码:
import UIKit
class EmojiPopup: UIView,UICollectionViewDataSource,UICollectionViewDelegate
{
var collocationView : UICollectionView!
var arrImagesList:NSMutableArray!
override init(frame: CGRect)
{
super.init(frame: frame)
arrImagesList = NSMutableArray()
self.backgroundColor = UIColor.purpleColor().colorWithAlphaComponent(0.1)
let layout = UICollectionViewFlowLayout()
//header gap
layout.headerReferenceSize = CGSizeMake(30,30)
//collection view item size
layout.itemSize = CGSizeMake(75, 75)
layout.minimumInteritemSpacing = 20
layout.minimumLineSpacing = 10
collocationView = UICollectionView(frame: CGRectMake(50,50,UIScreen.mainScreen().bounds.screenWidth - 100,UIScreen.mainScreen().bounds.screenHeight - 100), collectionViewLayout: layout)
self.addSubview(collocationView)
collocationView.backgroundColor = UIColor.purpleColor().colorWithAlphaComponent(0.001)
collocationView.dataSource = self
collocationView.delegate = self
collocationView.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: "cellIdentifier")
let fm = NSFileManager.defaultManager()
let path = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用分段控制按钮更改地图类型,我希望它可以使用3个选项更改地图类型:标准,卫星和混合.到目前为止,我有这个代码但是一旦选择了不同的地图类型就没有任何反应:
@IBAction func segmentedControlAction(sender: UISegmentedControl!) {
if sender.selectedSegmentIndex == 0{
mapView.mapType = MKMapType.Standard
}
else if sender.selectedSegmentIndex == 1{
mapView.mapType = MKMapType.Satellite
}
else if sender.selectedSegmentIndex == 3{
mapView.mapType = MKMapType.Hybrid
}
}
Run Code Online (Sandbox Code Playgroud)
我是Swift和Xcode的新手所以感谢任何帮助:)
谢谢
我正在设计餐馆网站的表格,允许用户预订晚餐预订,每个字段都经过验证(除了复选框),如果用户在所有字段中输入了正确的信息,他们会被发送到感谢页面显示他们的预订细节.
我的代码中存在与我网站上的复选框有关的问题,如果用户点击提交而未填写必填字段,则会在屏幕顶部显示以下错误:
"Notice: Undefined index: vege in /home/users/2014/xxx/public_html/xxx/index.php on line 17
Notice: Undefined index: vegan in /home/users/2014/xxx/public_html/xxx/index.php on line 20
Notice: Undefined index: peanut in /home/users/2014/xxx/public_html/xxx/index.php on line 23
Notice: Undefined index: gluten in /home/users/2014/xxx/public_html/xxx/index.php on line 26"
Run Code Online (Sandbox Code Playgroud)
这是我的预订页面的代码:
<?php
session_start();
if ( isset($_POST['vege']))
$_SESSION['vege'] = $_POST['vege'];
if ( isset($_POST['vegan']))
$_SESSION['vegan'] = $_POST['vegan'];
if ( isset($_POST['peanut']))
$_SESSION['peanut'] = $_POST['peanut'];
if ( isset($_POST['gluten']))
$_SESSION['gluten'] = $_POST['gluten'];
?>
...
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
...
<strong>Dietary Requirements:</strong>
<br><br>
Vegetarian <input type="checkbox" name="vege" …Run Code Online (Sandbox Code Playgroud)