- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将数据发送到我的适配器 View ,它应该在其中放置正确的数据。我通过“exerciseName”变量发送数据。在打印中它是正确的,但当它到达目的地时,第二个 View 它变成零。请帮忙
var workoutInfoData : WorkoutInfo!
var RoundLabels = ["Round 1","Round 2","Round 3","Round 4","Round 5","Round 6","Round 7","Round 8","Round 9","Round 10","Round 11","Round 12"]
var exerciseName:String = ""
var roundPosition = [Int]()
let numberOfExercises = 1
var scrollerSize = 0
override func viewDidLoad() {
super.viewDidLoad()
//self.workoutTitle.title! = workoutInfoData.workout_name
navigationItem.title = workoutInfoData.workout_name
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func workoutBack(sender: AnyObject) {
self.dismissViewControllerAnimated(true, completion: {});
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return RoundLabels.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
var cell : RoundWorkoutCell! = tableView.dequeueReusableCellWithIdentifier("Cell") as! RoundWorkoutCell
if(cell == nil)
{
cell = NSBundle.mainBundle().loadNibNamed("Cell", owner: self, options: nil)[0] as! RoundWorkoutCell;
}
let exerviseName = RoundLabels[indexPath.row]
if(indexPath.row == 1){
}
for countMe in 0..<self.numberOfExercises {
if(countMe<1){
roundPosition.append(5)
}else{
roundPosition.append(115+roundPosition[countMe-1])
}
scrollerSize = 115+roundPosition[countMe]
}
cell.RoundExercise_Cell_ScrollView.contentSize = CGSizeMake(CGFloat(scrollerSize),115)
cell.RoundExercise_Cell_ScrollView.showsHorizontalScrollIndicator = true
cell.RoundExercise_Cell_ScrollView.indicatorStyle = .Default
for index in 0..<self.numberOfExercises {
var imageView : UIImageView
imageView = UIImageView(frame:CGRect(x:roundPosition[index],y: 5, width:110, height: 110 ))
imageView.backgroundColor = UIColor.whiteColor()
cell.RoundExercise_Cell_ScrollView.addSubview(imageView)
let label1: UILabel = UILabel()
label1.frame = CGRect(x:roundPosition[index],y: 5, width:110, height: 20 )
label1.textColor = UIColor(red:17/255.0, green: 22/255.0, blue: 40/255.0, alpha:1.0)
label1.textAlignment = NSTextAlignment.Center
label1.font = UIFont(name: "OpenSans-CondensedLight", size: 14)
label1.text = "Pushups"
cell.RoundExercise_Cell_ScrollView.addSubview(label1)
let frame1 = CGRect(x:roundPosition[index]+10,y:25, width:90, height: 90 )
let button = UIButton(frame: frame1)
button.backgroundColor = UIColor.redColor()
button.setBackgroundImage(UIImage(named: "sit_thrust") as UIImage?, forState: .Normal)
button.setTitleColor(UIColor.blackColor(), forState: .Normal)
button.setTitle("air_sit_front_raise", forState: .Normal)
button.setTitleColor(UIColor(red:0/255,green:0/255,blue:0/255,alpha:0.0), forState: .Normal)
button.addTarget(self, action: "buttonClick:", forControlEvents: .TouchUpInside)
cell.RoundExercise_Cell_ScrollView.addSubview(button)
let label: UILabel = UILabel()
label.frame = CGRect(x:roundPosition[index],y: 115, width:110, height: 20 )
label.font = UIFont(name: "OpenSans", size: 14)
label.textColor = UIColor.whiteColor()
label.textAlignment = NSTextAlignment.Center
label.text = "30sec"
cell.RoundExercise_Cell_ScrollView.addSubview(label)
}
cell.RoundExercise_Cell_Label.text = exerviseName
return cell as RoundWorkoutCell
}
func buttonClick(sender:AnyObject){
exerciseName = String(sender.currentTitle)
//print(sender.currentTitle)
self.performSegueWithIdentifier("showExercise", sender:exerciseName)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showExercise" {
let vc = segue.destinationViewController as! ViewExerciseFromMenu
//vc.exerciseGet = UIImage(named: "sit_thrust")!
//vc.title = "SIT THRUSTS"
print(exerciseName)
vc.exerciseGet = exerciseName
navigationItem.title = "easy"
}
}
适配器 View
@IBOutlet var imageView: UIImageView!
@IBOutlet var musInvImageHolder: UIImageView!
var exerciseGet: String = ""
var image = UIImage()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
//var exerciseCurrent: String
print(exerciseGet)
switch(String(exerciseGet)){
case "air_sit_front_raise":
self.title = "AIR SIT FRONT RAISE"
musInvImageHolder.image = UIImage(named: "mus_inv_20")
let url = NSBundle.mainBundle().URLForResource("air_sit_front_raise", withExtension: "gif")!
let imageData = NSData(contentsOfURL: url)
imageView.image = UIImage.animatedImageWithData(imageData!)
break;
最佳答案
这里是解决办法
@IBOutlet var roundExercisesTable: UITableView!
var workoutInfoData : WorkoutInfo!
var RoundLabels = ["Round 1","Round 2","Round 3","Round 4","Round 5","Round 6","Round 7","Round 8","Round 9","Round 10","Round 11","Round 12"]
var exerciseName:String? = ""
var myButtons: [Int : UIButton] = [:]
var roundPosition = [Int]()
let numberOfExercises = 1
var scrollerSize = 0
let exerciseInfo=ExercisesInfo()
override func viewDidLoad()
{
super.viewDidLoad()
//self.workoutTitle.title! = workoutInfoData.workout_name
navigationItem.title = workoutInfoData.workout_name
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func workoutBack(sender: AnyObject) {
self.dismissViewControllerAnimated(true, completion: {});
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return RoundLabels.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
var cell : RoundWorkoutCell! = tableView.dequeueReusableCellWithIdentifier("Cell") as! RoundWorkoutCell
if(cell == nil)
{
cell = NSBundle.mainBundle().loadNibNamed("Cell", owner: self, options: nil)[0] as! RoundWorkoutCell;
}
let exerviseName = RoundLabels[indexPath.row]
if(indexPath.row == 1){
}
for countMe in 0..<self.numberOfExercises {
if(countMe<1){
roundPosition.append(5)
}else{
roundPosition.append(115+roundPosition[countMe-1])
}
scrollerSize = 115+roundPosition[countMe]
}
cell.RoundExercise_Cell_ScrollView.contentSize = CGSizeMake(CGFloat(scrollerSize),115)
cell.RoundExercise_Cell_ScrollView.showsHorizontalScrollIndicator = true
cell.RoundExercise_Cell_ScrollView.indicatorStyle = .Default
for index in 0..<self.numberOfExercises {
var imageView : UIImageView
imageView = UIImageView(frame:CGRect(x:roundPosition[index],y: 5, width:110, height: 110 ))
imageView.backgroundColor = UIColor.whiteColor()
cell.RoundExercise_Cell_ScrollView.addSubview(imageView)
let label1: UILabel = UILabel()
label1.frame = CGRect(x:roundPosition[index],y: 5, width:110, height: 20 )
label1.textColor = UIColor(red:17/255.0, green: 22/255.0, blue: 40/255.0, alpha:1.0)
label1.textAlignment = NSTextAlignment.Center
label1.font = UIFont(name: "OpenSans-CondensedLight", size: 14)
label1.text = "Pushups"
cell.RoundExercise_Cell_ScrollView.addSubview(label1)
let frame1 = CGRect(x:roundPosition[index]+10,y:25, width:90, height: 90 )
let button = UIButton(frame: frame1)
button.backgroundColor = UIColor.redColor()
button.setBackgroundImage(UIImage(named: "sit_thrust") as UIImage?, forState: .Normal)
button.setTitleColor(UIColor.blackColor(), forState: .Normal)
button.setTitle("air_sit_front_raise", forState: .Normal)
button.setTitleColor(UIColor(red:0/255,green:0/255,blue:0/255,alpha:0.0), forState: .Normal)
button.addTarget(self, action: "buttonClick:", forControlEvents: .TouchUpInside)
cell.RoundExercise_Cell_ScrollView.addSubview(button)
let label: UILabel = UILabel()
label.frame = CGRect(x:roundPosition[index],y: 115, width:110, height: 20 )
label.font = UIFont(name: "OpenSans", size: 14)
label.textColor = UIColor.whiteColor()
label.textAlignment = NSTextAlignment.Center
label.text = "30sec"
cell.RoundExercise_Cell_ScrollView.addSubview(label)
}
cell.RoundExercise_Cell_Label.text = exerviseName
return cell as RoundWorkoutCell
}
func buttonClick(sender:AnyObject){
exerciseName = sender.currentTitle
//print(sender.currentTitle)
self.performSegueWithIdentifier("showExercise", sender:exerciseName)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showExercise" {
let vc = segue.destinationViewController as! ViewExerciseFromMenu
//vc.exerciseGet = UIImage(named: "sit_thrust")!
//vc.title = "SIT THRUSTS"
print(exerciseName)
vc.exerciseGet = exerciseName!
navigationItem.title = exerciseInfo.hradnesExerciseDeterminer(exerciseName!)
}
}
关于iOS Swift PerformSegueWithIdentifier 用于发送数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33199989/
我的主视图 Controller 位于导航 Controller 中,它符合 EditViewControllerDelegate 协议(protocol)。这是我需要以模态方式呈现的两个 View
所以我在解决以下问题时遇到了一些棘手的问题。我可以使用 performSegueWithIdentifier使用如下代码在 View Controller 之间跳转: [self performSeg
我在 iOS7 中遇到问题,我用 performSegueWithIdentifier 调用 segue (我有这样的代码,几乎可以在其他任何地方使用),然后我将 segue 记录到 prepareF
我有一个带有按钮的 View Controller ,可以通过 STTwitter 启动 Twitter 登录页面。 . shouldPerformSegueWithIdentifier函数返回 NO
-(void)loginPerform { NSLog(@"start to perform segue!"); [self performSegueWithIdentifier:@"
我只是想问一下如何执行seguewithidentifier并打开一个新 View , 当信标位于应用程序范围内时。 请帮助我并提供示例和文档。谢谢。 最佳答案 您应该查看的教程: Ray Wende
因此,我尝试在窗口加载后立即执行转场,而无需单击按钮或执行任何操作。 Segue 是从 View Controller 链接的,但不是从窗口 Controller 链接的,因为我一次只能从 Windo
我有 6 个不同的表,当选择其中一个表中的行时(在 RegionFirstTable 中,哪个表很重要),我希望它们执行 Segue。 regionsFirstTable 的代码工作正常,但至于其他部
我只是构建了一个类来正确管理我的数据库和 JSON 请求。问题是,现在我该如何执行 segue ? 这是我的代码在我看来: - (IBAction)loginClick:(id)sender {
当我点击一个按钮时,我会运行这段代码: [self performSegueWithIdentifier:@"services" sender:self]; NSLog(@"ButtonClicked
我想通过 performSegueWithIdentifier(self.segueName, sender: products) 传递类型为 [Product] 的名为 products 的数组 我
您好,我正在尝试根据用户的选择推送到不同的 View 。我有一个 TableView ,其中有 4 个其他 View Controller 通过 Storyboard中的推送 segues 链接到它。
我有这样一个问题,当我点击按钮时,performSegueWithIdentifier() 会延迟工作,大约五秒钟,但是当我返回并再次点击按钮时,它会立即工作,没有任何延迟。 我想知道是否有 perf
我正在尝试使用 segue,这是我的代码: if let status_code = response.response?.statusCode { if status_code == 200
我已经阅读了很多关于这个问题的不同帖子,但似乎没有一个解决方案适合我。 我启动了一个新的应用程序,并将初始的 ViewController 放在导航 Controller 中。我创建了第二个 View
我正在 XCode 6 上使用框架 PARSE 设置注册/登录页面。 当我尝试执行一个 segue(它拼写正确)时,悬停,应用程序崩溃,即使 segue 在 if 语句中也是如此。 代码如下: imp
简单的测试显示了 performSegueWithIdentifier 之后的方法可以执行,但是做这个假设是否安全? Apple 文档未提及此主题。 例如,下面代码块中的print 语句在测试中执行。
我有一个项目,其中有一个 Storyboard。 Storyboard包含几个 View Controller 。我将简化它并省略不必要的细节。在 Navigation Controller 中,有几
我有这段代码可以使用信标更新距离。 func updateDistance(distance: CLProximity) { UIView.animateWithDuration(0.8) {
我的应用遇到了这种奇怪的情况。我在主线程上调用 performSegueWithIdentifier : dispatch_async(dispatch_get_main_queue()){
我是一名优秀的程序员,十分优秀!