Posts

Post not yet marked as solved
0 Replies
338 Views
I am using the following method to obtain a list of GameCenter "friends" and it returns a list of player names on my iPhone 8 ( iOS 13.3 ) loadChallengableFriends(completionHandler: )When this method is called on an iPhone 6 ( iOS 12.4.4), I get the following error relating to the "loadChallengableFriends( )" method loadChallengableFriendsWithCompletionHandler:]: unrecognized selector sent to instance *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GKLocalPlayerInternal loadChallengableFriendsWithCompletionHandler:]: unrecognized selector sent to instanceI was informed the iPhone 6 models no longer receive updates from Apple so this iPhone 6 is stuck at iOS 12.4.4 version.Since the loadChallengableFriends( ) method works on the iPhone 8 (iOS 13.3) and does not work on the iPhone 6 (iOS 12.4.4), I was thinking perhaps this method does not exist in iOS 12+The Apple documentation indicates the following for all of the "friends" methods I could find:a) loadChallengableFriends( ) SDK iOS 13+b) loadFriendPlayers( ) SDK iOS 8.0 - 10.0 (deprecated)c) loadFriends( ) SDK iOS 4.1- 8.0. (deprecated)Questions1) Do I interpret the "SDK iOS 13+" statement to mean the loadChallengableFriends( ) method does not exist before iOS 13?2) What method do we use to find "friends" between "iOS 10 and iOS 13" then ? Perhaps this is not supported durine that time?
Posted
by uncletr.
Last updated
.
Post marked as solved
20 Replies
14k Views
I want to use a Scrollview on the middle 2/3 of the screen so I did the following:1) I added a BaseView UIView to the middle 2/3 of my MainViewController and set the constraints to the following:leading =0trailing =0top to safe area = 150bottom to safe area = 1502) I added a MyScrollView inside the BaseView and set the constraints as follows:Note: All MyScrollview constraints remain RED after setting these constraints :>(leading = 0trailing = 0top = 0bottom = 03) I added a MyDataView UIView object inside the MyScrollView . The MyDataView starts at (0,0) and has a size of 500x500. I tried setting constraints on MyDataView to the following values but the top and leading constraints remain RED, most likely because the MyScrollView constraints are RED (see 2 above)top=0leading=0width=500height=5004) In the viewDidLoad function I added the following:ScrollView.delegate = selfScrollView.contentsize = MyDataView.frame.size5) I added various objects (buttons, labels, etc.) in the MyDataView UIView and tried to set constraints on these objects but the constraints are all RED as well. Questions:1) I am setting up the ScrollView properly so it can be used for 2/3 of the screen area only?2) How can I set valid constraints for the objects placed in the MyDataView and have them be a nice BLUE color?
Posted
by uncletr.
Last updated
.
Post marked as solved
6 Replies
1k Views
I am able to start a 2-player match between the IOS simluator and my connected iPhone. The IOS simulator starts hunting for a two player game using the GameKit Matchmaker View Controller and the iPhone requests a two-player match by entering my game application as well. Of course, the IOS simulator and my iPhone are using separate Game Center accounts to make this possible.I now want to test sending a true "Invite" request from the IOS simulator to the iPhone. When requesting a match in the IOS simulator, I can see my iPhone "user" is listed under the "Recently Played" section of the GameKit Matchmaker View Controller display window, after clicking the "Invite Player" button of course. When I select my iPhone "user" and then select "Play Now", my iPhone never receives an Invite request because the IOS simulator generates the following error:GKMatchmaker: invitePlayersWithRequest: - Error Inviting Players Error Domain=GKErrorDomain Code=3 "The requested operation could not be completed due to an error communicating with the server." UserInfo=GKServerStatusCode=5008, NSLocalizedDescription=The requested operation could not be completed due to an error communicating with the server., NSUnderlyingError=0x600002761c20 Error Domain=GKServerErrorDomain Code=5008 "status = 5008, missing required key: self-push-token" UserInfo={GKServerStatusCode=5008, NSLocalizedFailureReason=status = 5008, missing required key: self-push-tokenCan the IOS simulator be used to Invite iPhone users? If so, what does the error mean and how can I fix it?Does my iPhone have to be inside my game application to make this work ... I hope not.
Posted
by uncletr.
Last updated
.
Post marked as solved
2 Replies
700 Views
The Game Center Programming Guide clearly states real-time peer-to-peer matches supports 2 to 4 players only. However, I just notced I can call the findMatchWithMinPlayers method with the request.maxPlayers parameter set to a value of 5->16 and the GKMatchmakerViewController presents 5->16 players for me to invite.Is the Game Center Programming Guide out-of-date and real-time peer-to-peer matches support more than 4 players are now?I would like to know for sure so I can enable more than 4 player support into my game.
Posted
by uncletr.
Last updated
.
Post marked as solved
2 Replies
893 Views
Do you know how the GKMatchmakerViewController handles a decline from a player (friend) who was listed in the "request.recipient" array? Does Game Center then automatically hunt for some random player or does the match request fail?
Posted
by uncletr.
Last updated
.
Post marked as solved
11 Replies
975 Views
When a user is not currently in the game application, I understand Game Center with push an Invite notification to the user's device asking them if they want to play the game. If they accept the invitation then Game Center will open the application automatically on the user's device. How can the game application know it was started as a result of an accepted invitation? If this can be determined then I can place the user into the game right away and bypass any option screens, displays menus, etc. which are no longer required.
Posted
by uncletr.
Last updated
.
Post marked as solved
25 Replies
5.4k Views
I am using Swift 4.I am able to authenticate the localplayer and find a match using the Game Center match viewcontroller. I was also able to link the iOS simulator (player1) to my real iPhone 8 device (player2) into a match for test purposes.However, after the localplayer is authenticated, I would like to obtain a list of all my game center "friends" myself and then create my own viewController interface to invite/connect players into the game. I was able to call "GKLocalPlayer.local.loadChallengableFriends( )" to obtain the friends, but I am not sure how to properly invite them to a match one by one programmatically.Googling indicates GKMatchmaker inviteHandler, GKInvite and "player DidAccept" are involved but I do not know how to put this all together.Any pointers, hints or sample code would be greatly appreciated.In the meantime, I will continue to Google around
Posted
by uncletr.
Last updated
.
Post marked as solved
4 Replies
511 Views
I am able to authenticate the localplayer and find a match using the Game Center match viewcontroller. Assuming the match is going to have 4 players, I would like to ensure only 1 player sets the game options before they are matched with 3 other players. Of course, the 3 other players must know they should not set game options themselves. Any idea how this is done?
Posted
by uncletr.
Last updated
.
Post marked as solved
18 Replies
4.8k Views
I want to click a button and have my View slowly animate into the viewing area from the right side of the screen. Then click a second button and have the view animate off the screen from left to rightI added a Button (OpenButton with IBAction = openView) and a View (DataView) into my main ViewController. I set constraints on DataView to be the safe area for top(20), bottom(20), leading(16) and trailing(16). I also added a Button (CloseButton with IBAction = closeView) into the DataView.While in Portrait mode, clicking the OpenButton results in the OpenView( ) function being called and the DataView animating properly from right to left into the visible screen as desired. Clicking the CloseButton results in the view animating off the screen from left to right as desired. (Note: There are no calls to viewWillLayoutSubviews( ) which are made by the system at this time). I can click OpenButton and CloseButton multiple times and the animation works great each time while in Portrait mode.I now switched to Landscape mode. Clicking the OpenButton results in the openView( ) function being called and the DataView animating properly from right to left into the visible screen as desired. Clicking the CloseButton results in weird animation in the wrong places and the DataView does not properly go off the screen. Debugging has shown that when the CloseButton is pressed, then viewWillLayoutSubviews() and viewDidLayoutSubviews( ) are called, then the closeView( ) function is called and then viewWillLayoutSubviews() and viewDidLayoutSubviews( ) are called a second time. When viewDidLayoutSubviews() is called a second time, then the DataView snaps back to it's origin.x constraint value of 16 which results in it moving back to the leading safe area, which affects the animation which is currently going on. It seems like that is what is messes up the animation.Debug "print" statement output <Note: OPEN button clicked here>openScoreWindow -- enter dataView.frame.origin.x = 16.0 animation complete - openScoreWindow<Note: CLOSE button clicked here>viewWillLayoutSubviews dataView.frame.origin.x = 16.0viewDidLayoutSubviews dataView.frame.origin.x = 16.0closeScoreWindow -- enter dataView.frame.origin.x = 16.0viewWillLayoutSubviews dataView.frame.origin.x = 767.0 <--- this value is set in the UIVIew_Animate( ) in the closeView( ) function, as desiredviewDidLayoutSubviews dataView.frame.origin.x = 16.0 <--- this is proof the "leading" constraint is reset back to 16 during the active animation animation complete - closeScoreWindow . <-- this is when animation has completed** I tried to replicate this scenario by creating a separate brand new swift "test project" which just had the two buttons and dataView, however, in this "test project", the animation in portrait and landscape mode works as desired since viewWillLayoutSubviews() is never called when opening and closing the view. Oh well, for some reason, in my project, viewWillLayoutSubviews() is called twice when I click the Close button.I have no idea how to get around this issue. Any ideas?override func viewDidLoad() { super.viewDidLoad() dataView.isHidden = true print ("viewDidLayoutSubviews") print(" dataView.frame.origin.x = \(dataView.frame.origin.x)") print("") } @IBAction func openView() { print("openScoreWindow -- enter") print(" dataView.frame.origin.x = \(dataView.frame.origin.x)") //ensure view is positoned out of the viewing area dataView.frame.origin.x = getScreenSize().width + 100 //make view visible for eventual animation dataView.isHidden = false //animate view moving from right to left onto the screen UIView.animate(withDuration: 1.0, //1 second delay: 0, options: .curveEaseInOut, animations: { self.dataView.frame.origin.x = 16 }, completion: { [weak self] finished in print(" animation complete - openScoreWindow") print("") }) } } @IBAction func closeView() { print("closeScoreWindow -- enter") print(" dataView.frame.origin.x = \(dataView.frame.origin.x)") //animate view moving from left to right off the screen UIView.animate(withDuration: 3.0, //1 second delay: 0, options: .curveEaseInOut, animations: { //move view out of the viewing area self.dataView.frame.origin.x = self.getScreenSize().width + 100 }, completion: { [weak self] finished in //hide the view self?.dataView.isHidden = true print(" animation complete - closeScoreWindow") print("") }) }
Posted
by uncletr.
Last updated
.
Post marked as solved
2 Replies
673 Views
I am making an application to work on many various iPhone models in portrait mode. I would like to have a button (with fixed height) always be afixed at a position 2/3 way down the screen display area no matter what iPhone model is used. I understand I can do this by pinning two views in the storyboard and then setting Equal heights with 1:3 and 2:3 ratios, however, is there a way to do this without introducing two views into the storyabord for this purpose?
Posted
by uncletr.
Last updated
.
Post marked as solved
6 Replies
725 Views
I have two buttons of the same size (ie: Button1 and Button2). Button2 overlaps Button1 by 50% (see below).If I click anywhere within Button2 then I receive an IBAction Click notification from Button2, as expected.If I click anywhere within Button1 then I receive an IBAction Cick notification from Button1, as expected.IssueIf Button2 is now disabled (ie: Button2.isEnabled = false) or user interaction set to false (ie: Button2.isUserInteractionEnabled = false) and I click on the left 50% of Button2 area (ie: the area which is overlapping Button1), then I will receive an IBAction Click notification from Button1QuestionsWhy do I receive an IBAction Click notification from Button1 when clicking disabled Button2 ?I would expect not to receive any IBAction Click notifications when clicking anywhere within the area of Button2I think I can work around this issue in code, however, I was wondering whether this is normal handling and how others might resolve this behavior.
Posted
by uncletr.
Last updated
.
Post marked as solved
1 Replies
690 Views
Why is my post stuck in DRAFT for 24 hours with the following statement: "Please note: your content was added successfully, but a moderator needs to approve it before it can be posted" https://forums.developer.apple.com/thread/125251Someone replied to it, however, I cannot add a reply to it myself. I receive the following: "Sorry, but you are not authorized to reply to this discussion."
Posted
by uncletr.
Last updated
.
Post marked as solved
3 Replies
950 Views
I am playing around and learning how to display an alert and I am seeing unexpected behaviorBased on the code snippet below, you can see there is a local variable defined as "result = false".The alert message is displayed, which asks the user to enter "YES" or "NO"When I click the "YES" button, I see "YES" text displayed, as expected in the handlerWhen I click the "NO" button, I see "NO" text displayed, as expected in the handlerIssue:I never see the "print" in Line 19 displayed ever. What is going on please?var result = false let alert = UIAlertController(title: "Testing", message: "Hello", preferredStyle: .alert) alert.addAction(UIAlertAction(title: "YES", style: .destructive, handler: { action in result = true print("YES") } )) alert.addAction(UIAlertAction(title: "NO", style: .cancel, handler: { action in result = false print("NO") } )) present(alert, animated: true, completion: nil) print("result=\(result)")
Posted
by uncletr.
Last updated
.
Post marked as solved
7 Replies
1.4k Views
I am playing around to learn interface builder constraints. My current project has a lot of subviews and constraints set, however, for the sake of asking my qustion, I reduced the scope down to the basics (read below).Using interface builder, I added a UIView to my project and pinned it to the top, leading, trailing and bottom safe area. I then added a button and a TableView to the UIView, where the button is positioned on top of the TableView. The button and TableView are then added into a vertical StackView.How it worksThe TableView was configured with four rows where each row has a text string. When the button is clicked, the TableView is made visible (ie: isHidden=false) and the StackView height increases. One of the rows in the TableView is selected and the button title is updated with the text string associated with the row which was selected. The TableView is then hidden from view (ie: isHidden = true) and the StackView height decreases. This all works as expectedMy GoalWhen the TableView is hidden, I would like to decrease the height of my UIView by the same amount as the StackView decreases. When the TableView is made visible, I would like to increase the height of my UIView by the same amount as the StackView increases. Basically, the UIView height becomes variable based on whether the TableView is hidden or not hidden.QuestionI think I need to remove the "Bottom Alignment Constraint" for my UIView so it is no longer set to the bottom safe area, but then how can I set this constraint properly based on the variable size of the StackView ?Important NoteIf I simply decide not to assign a "Bottom Alignment Constraint" for my UIView to the safe area, then when I run my project, my compelte UIView is not seen, since the height of the UIView becomes 0. As a result, it seems like I need to have this bottom constraint set somehow
Posted
by uncletr.
Last updated
.
Post marked as solved
15 Replies
4.1k Views
I am playing around with Pinch Gesture for fun to try to learn, however, I do not see my "PINCH" print statement displayed in the console.QuestionWhy does my print("PINCH") statement not show up in the Console when the code is run?(Note: After the program is running in the simulator, I press the <Option> key and see the two "pinch" circles. I then use the mouse to move the circles closer together and then farther apart)Initial Setup- Added a new ViewController in my storyboard- Created a New Cocoa Touch File (type of ViewController) and called it "GesturesViewController"- Associated the "GesturesViewController" class with the ViewController object I added previously so they are linked- Dragged a UIView object on the ViewController and resized it to be large- Created an IBOutlet of the UIView and called it "letterView" (see code added below)- Defined the pinch gesture recognizer within the didSet{ } of the IBOutlet letterView to call "processPinch" method (see code below)- Run the code, do the "pinching" with the two circles and the mouse and the "PINCH" text does not show up in the ConsoleCode:import UIKit class GesturesViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() } @IBOutlet weak var letterView: UIView! { didSet { let pinch = UIPinchGestureRecognizer(target: self, action: #selector(processPinch(_:))) letterView.addGestureRecognizer(pinch) } } @objc func processPinch(_ sender: UIPinchGestureRecognizer) { print("PINCH") } }
Posted
by uncletr.
Last updated
.