Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
810d36d0
Commit
810d36d0
authored
10 years ago
by
Maxime Graulich
Browse files
Options
Downloads
Patches
Plain Diff
iOS: fix selectValue for iOS8
parent
b214156c
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
contrib/mobile/iOS/Onelab/Parameter.mm
+32
-9
32 additions, 9 deletions
contrib/mobile/iOS/Onelab/Parameter.mm
contrib/mobile/iOS/Onelab/Utils.h
+3
-0
3 additions, 0 deletions
contrib/mobile/iOS/Onelab/Utils.h
contrib/mobile/iOS/Onelab/Utils.mm
+11
-0
11 additions, 0 deletions
contrib/mobile/iOS/Onelab/Utils.mm
with
46 additions
and
9 deletions
contrib/mobile/iOS/Onelab/Parameter.mm
+
32
−
9
View file @
810d36d0
#import "parameter.h"
#import "Utils.h"
@implementation
Parameter
-
(
id
)
init
...
...
@@ -141,20 +142,42 @@
-
(
void
)
selectValue
{
std
::
vector
<
onelab
::
number
>
number
;
onelab
::
server
::
instance
()
->
get
(
number
,[
name
UTF8String
]);
if
(
number
.
size
()
<
1
)
return
;
UIActionSheet
*
popupSelectValue
=
[[
UIActionSheet
alloc
]
initWithTitle
:[
NSString
stringWithFormat
:
@"%s"
,
number
[
0
].
getLabel
().
c_str
()]
delegate
:
self
cancelButtonTitle
:
nil
destructiveButtonTitle
:
nil
otherButtonTitles
:
nil
];
std
::
vector
<
double
>
choices
=
number
[
0
].
getChoices
();
std
::
vector
<
onelab
::
number
>
numbers
;
onelab
::
server
::
instance
()
->
get
(
numbers
,[
name
UTF8String
]);
onelab
::
number
number
=
numbers
[
0
];
if
(
numbers
.
size
()
<
1
)
return
;
UIAlertController
*
alertController
;
UIAlertAction
*
destroyAction
;
alertController
=
[
UIAlertController
alertControllerWithTitle
:
nil
message
:
nil
preferredStyle
:
UIAlertControllerStyleActionSheet
];
std
::
vector
<
double
>
choices
=
numbers
[
0
].
getChoices
();
for
(
int
i
=
0
;
i
<
choices
.
size
();
i
++
)
[
popupSelectValue
addButtonWithTitle
:[
NSString
stringWithFormat
:
@"%s"
,
number
[
0
].
getValueLabel
(
choices
[
i
]).
c_str
()]];
[
popupSelectValue
addButtonWithTitle
:
@"Cancel"
];
[
popupSelectValue
setCancelButtonIndex
:
popupSelectValue
.
numberOfButtons
-
1
];
[
popupSelectValue
showInView
:
button
];
[
alertController
addAction
:[
UIAlertAction
actionWithTitle
:[
NSString
stringWithFormat
:
@"%s"
,
numbers
[
0
].
getValueLabel
(
choices
[
i
]).
c_str
()]
style:
UIAlertActionStyleDefault
handler:
^
(
UIAlertAction
*
action
)
{
std
::
cout
<<
numbers
[
0
].
getValueLabel
(
i
).
c_str
()
<<
std
::
endl
;
//FIXME number.setValue(i);
onelab
::
server
::
instance
()
->
set
(
numbers
[
0
]);
[
button
setTitle
:[
NSString
stringWithFormat
:
@"%s"
,
numbers
[
0
].
getValueLabel
(
numbers
[
0
].
getValue
()).
c_str
()]
forState
:
UIControlStateNormal
];
}]];
destroyAction
=
[
UIAlertAction
actionWithTitle
:
@"Cancel"
style:
UIAlertActionStyleDestructive
handler:
^
(
UIAlertAction
*
action
)
{
// do nothing
}];
[
alertController
addAction
:
destroyAction
];
[
alertController
setModalPresentationStyle
:
UIModalPresentationPopover
];
UIPopoverPresentationController
*
popPresenter
=
[
alertController
popoverPresentationController
];
popPresenter
.
sourceView
=
button
;
popPresenter
.
sourceRect
=
button
.
bounds
;
[[
Utils
traverseResponderChainForUIViewController
:
button
]
presentViewController
:
alertController
animated
:
YES
completion
:
nil
];
// FIXME traverseResponderChainForUIViewController is a goo idea ??
}
-
(
void
)
actionSheet
:(
UIActionSheet
*
)
actionSheet
clickedButtonAtIndex
:(
NSInteger
)
buttonIndex
{
std
::
cout
<<
(
"COUCOU ..."
)
<<
std
::
endl
;
std
::
vector
<
onelab
::
number
>
number
;
onelab
::
server
::
instance
()
->
get
(
number
,[
name
UTF8String
]);
if
(
number
.
size
()
<
1
)
return
;
...
...
This diff is collapsed.
Click to expand it.
contrib/mobile/iOS/Onelab/Utils.h
+
3
−
0
View file @
810d36d0
...
...
@@ -5,4 +5,7 @@
+
(
NSString
*
)
getApplicationDocumentsDirectory
;
+
(
void
)
copyRes
;
+
(
id
)
traverseResponderChainForUIViewController
:(
UIView
*
)
v
;
@end
This diff is collapsed.
Click to expand it.
contrib/mobile/iOS/Onelab/Utils.mm
+
11
−
0
View file @
810d36d0
...
...
@@ -26,4 +26,15 @@
}
}
+
(
UIViewController
*
)
traverseResponderChainForUIViewController
:(
UIView
*
)
v
{
id
nextResponder
=
[
v
nextResponder
];
if
([
nextResponder
isKindOfClass
:[
UIViewController
class
]])
return
nextResponder
;
else
if
([
nextResponder
isKindOfClass
:[
UIView
class
]])
return
[
Utils
traverseResponderChainForUIViewController
:
nextResponder
];
else
return
nil
;
}
@end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment